@@ -1378,6 +1378,22 @@ func (q *QuotaCenter) checkDiskQuota(denyWritingDBs map[int64]struct{}) error {
13781378 return err
13791379 }
13801380
1381+ // check disk quota of loaded collections
1382+ totalLoadedDiskQuota := Params .QuotaConfig .LoadedDiskQuota .GetAsFloat ()
1383+ totalLoaded := 0.0
1384+ for _ , queryNodeMetrics := range q .queryNodeMetrics {
1385+ // for streaming node, queryNodeMetrics.LoadedBinlogSize is always 0
1386+ totalLoaded += float64 (queryNodeMetrics .LoadedBinlogSize )
1387+ }
1388+ if totalLoaded >= totalLoadedDiskQuota {
1389+ log .RatedWarn (10 , "cluster loaded disk quota exceeded" , zap .Float64 ("total loaded" , totalLoaded ), zap .Float64 ("total loaded disk quota" , totalLoadedDiskQuota ))
1390+ err := q .forceDenyWriting (commonpb .ErrorCode_DiskQuotaExhausted , true , nil , nil , nil )
1391+ if err != nil {
1392+ log .Warn ("fail to force deny writing" , zap .Error (err ))
1393+ }
1394+ return err
1395+ }
1396+
13811397 collectionDiskQuota := Params .QuotaConfig .DiskQuotaPerCollection .GetAsFloat ()
13821398 dbSizeInfo := make (map [int64 ]int64 )
13831399 collections := make ([]int64 , 0 )
@@ -1434,7 +1450,7 @@ func (q *QuotaCenter) checkDiskQuota(denyWritingDBs map[int64]struct{}) error {
14341450func (q * QuotaCenter ) checkDBDiskQuota (dbSizeInfo map [int64 ]int64 ) []int64 {
14351451 log := log .Ctx (context .Background ()).WithRateGroup ("rootcoord.QuotaCenter" , 1.0 , 60.0 )
14361452 dbIDs := make ([]int64 , 0 )
1437- checkDiskQuota := func (dbID , binlogSize int64 , quota float64 ) {
1453+ appendIfExceeded := func (dbID , binlogSize int64 , quota float64 ) {
14381454 if float64 (binlogSize ) >= quota {
14391455 log .RatedWarn (10 , "db disk quota exceeded" ,
14401456 zap .Int64 ("db" , dbID ),
@@ -1451,7 +1467,7 @@ func (q *QuotaCenter) checkDBDiskQuota(dbSizeInfo map[int64]int64) []int64 {
14511467 if dbDiskQuotaStr := db .GetProperty (common .DatabaseDiskQuotaKey ); dbDiskQuotaStr != "" {
14521468 if dbDiskQuotaBytes , err := strconv .ParseFloat (dbDiskQuotaStr , 64 ); err == nil {
14531469 dbDiskQuotaMB := dbDiskQuotaBytes * 1024 * 1024
1454- checkDiskQuota (dbID , binlogSize , dbDiskQuotaMB )
1470+ appendIfExceeded (dbID , binlogSize , dbDiskQuotaMB )
14551471 continue
14561472 } else {
14571473 log .Warn ("invalid configuration for diskQuota.mb" ,
@@ -1460,7 +1476,7 @@ func (q *QuotaCenter) checkDBDiskQuota(dbSizeInfo map[int64]int64) []int64 {
14601476 }
14611477 }
14621478 }
1463- checkDiskQuota (dbID , binlogSize , Params .QuotaConfig .DiskQuotaPerDB .GetAsFloat ())
1479+ appendIfExceeded (dbID , binlogSize , Params .QuotaConfig .DiskQuotaPerDB .GetAsFloat ())
14641480 }
14651481 return dbIDs
14661482}
0 commit comments