From d8aa01bc1a6d5508353377d67a03d1da3e3ffae4 Mon Sep 17 00:00:00 2001 From: jaime Date: Wed, 28 Aug 2024 11:21:04 +0800 Subject: [PATCH] fix: inconsistent meta view causes rate limit invalid (#35665) issue: #35663 Signed-off-by: jaime --- internal/rootcoord/quota_center.go | 13 ++++++------- internal/rootcoord/quota_center_test.go | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/rootcoord/quota_center.go b/internal/rootcoord/quota_center.go index 65d1e9f268..9dd91350c4 100644 --- a/internal/rootcoord/quota_center.go +++ b/internal/rootcoord/quota_center.go @@ -406,7 +406,7 @@ func (q *QuotaCenter) collectMetrics() error { collections.Range(func(collectionID int64) bool { coll, getErr := q.meta.GetCollectionByIDWithMaxTs(context.TODO(), collectionID) if getErr != nil { - rangeErr = getErr + // skip limit check if the collection meta has been removed from rootcoord meta return false } collIDToPartIDs, ok := q.readableCollections[coll.DBID] @@ -458,11 +458,11 @@ func (q *QuotaCenter) collectMetrics() error { if cm != nil { collectionMetrics = cm.Collections } - var rangeErr error + collections.Range(func(collectionID int64) bool { coll, getErr := q.meta.GetCollectionByIDWithMaxTs(context.TODO(), collectionID) if getErr != nil { - rangeErr = getErr + // skip limit check if the collection meta has been removed from rootcoord meta return false } @@ -494,9 +494,7 @@ func (q *QuotaCenter) collectMetrics() error { } return true }) - if rangeErr != nil { - return rangeErr - } + for _, collectionID := range datacoordQuotaCollections { _, ok := q.collectionIDToDBID.Get(collectionID) if ok { @@ -504,7 +502,8 @@ func (q *QuotaCenter) collectMetrics() error { } coll, getErr := q.meta.GetCollectionByIDWithMaxTs(context.TODO(), collectionID) if getErr != nil { - return getErr + // skip limit check if the collection meta has been removed from rootcoord meta + continue } q.collectionIDToDBID.Insert(collectionID, coll.DBID) q.collections.Insert(FormatCollectionKey(coll.DBID, coll.Name), collectionID) diff --git a/internal/rootcoord/quota_center_test.go b/internal/rootcoord/quota_center_test.go index 2fb0803916..aa93e586fc 100644 --- a/internal/rootcoord/quota_center_test.go +++ b/internal/rootcoord/quota_center_test.go @@ -245,7 +245,7 @@ func TestQuotaCenter(t *testing.T) { quotaCenter := NewQuotaCenter(pcm2, qc, dc2, core.tsoAllocator, meta) err = quotaCenter.collectMetrics() - assert.Error(t, err) + assert.NoError(t, err) }) t.Run("get collection by id fail, datanode", func(t *testing.T) { @@ -289,7 +289,7 @@ func TestQuotaCenter(t *testing.T) { quotaCenter := NewQuotaCenter(pcm2, qc, dc2, core.tsoAllocator, meta) err = quotaCenter.collectMetrics() - assert.Error(t, err) + assert.NoError(t, err) }) t.Run("test force deny reading collection", func(t *testing.T) {