fix: inconsistent meta view causes rate limit invalid (#35665)

issue: #35663

Signed-off-by: jaime <yun.zhang@zilliz.com>
This commit is contained in:
jaime 2024-08-28 11:21:04 +08:00 committed by GitHub
parent b7ea1defd3
commit d8aa01bc1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View File

@ -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)

View File

@ -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) {