enhance: Ignore db not found error in quota center (#36821)

In quota center, ignore the "DB not found error" to prevent it from
affecting the rate limiting of other databases.

/kind improvement

---------

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
yihao.dai 2024-10-15 15:55:22 +08:00 committed by GitHub
parent b0d5866507
commit 1bd3228635
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -571,7 +571,8 @@ func (q *QuotaCenter) forceDenyWriting(errorCode commonpb.ErrorCode, cluster boo
for _, collectionID := range collectionIDs {
dbID, ok := q.collectionIDToDBID.Get(collectionID)
if !ok {
return fmt.Errorf("db ID not found of collection ID: %d", collectionID)
log.Warn("cannot find db for collection", zap.Int64("collection", collectionID))
continue
}
collectionLimiter := q.rateLimiter.GetCollectionLimiters(dbID, collectionID)
if collectionLimiter == nil {
@ -588,7 +589,8 @@ func (q *QuotaCenter) forceDenyWriting(errorCode commonpb.ErrorCode, cluster boo
for _, partitionID := range partitionIDs {
dbID, ok := q.collectionIDToDBID.Get(collectionID)
if !ok {
return fmt.Errorf("db ID not found of collection ID: %d", collectionID)
log.Warn("cannot find db for collection", zap.Int64("collection", collectionID))
continue
}
partitionLimiter := q.rateLimiter.GetPartitionLimiters(dbID, collectionID, partitionID)
if partitionLimiter == nil {
@ -778,7 +780,8 @@ func (q *QuotaCenter) calculateWriteRates() error {
dbID, ok := q.collectionIDToDBID.Get(collection)
if !ok {
return fmt.Errorf("db ID not found of collection ID: %d", collection)
log.Warn("cannot find db for collection", zap.Int64("collection", collection))
continue
}
collectionLimiter := q.rateLimiter.GetCollectionLimiters(dbID, collection)
if collectionLimiter == nil {
@ -1230,7 +1233,7 @@ func (q *QuotaCenter) checkDiskQuota(denyWritingDBs map[int64]struct{}) error {
}
dbID, ok := q.collectionIDToDBID.Get(collection)
if !ok {
log.Warn("cannot find db id for collection", zap.Int64("collection", collection))
log.Warn("cannot find db for collection", zap.Int64("collection", collection))
continue
}

View File

@ -349,7 +349,7 @@ func TestQuotaCenter(t *testing.T) {
assert.NoError(t, err)
err = quotaCenter.forceDenyWriting(commonpb.ErrorCode_ForceDeny, false, nil, []int64{4}, nil)
assert.Error(t, err)
assert.NoError(t, err)
err = quotaCenter.forceDenyWriting(commonpb.ErrorCode_ForceDeny, false, nil, []int64{1, 2, 3}, map[int64][]int64{
1: {1000},