mirror of https://github.com/milvus-io/milvus.git
Fix quota center assignment to entry in nil map (#23819)
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>pull/23822/head
parent
c955c26656
commit
5a9a86ba74
|
@ -454,13 +454,13 @@ func (q *QuotaCenter) calculateWriteRates() error {
|
|||
func (q *QuotaCenter) getTimeTickDelayFactor(ts Timestamp) map[int64]float64 {
|
||||
log := log.Ctx(context.Background()).WithRateGroup("rootcoord.QuotaCenter", 1.0, 60.0)
|
||||
if !Params.QuotaConfig.TtProtectionEnabled.GetAsBool() {
|
||||
return nil
|
||||
return make(map[int64]float64)
|
||||
}
|
||||
|
||||
maxDelay := Params.QuotaConfig.MaxTimeTickDelay.GetAsDuration(time.Second)
|
||||
if maxDelay < 0 {
|
||||
// < 0 means disable tt protection
|
||||
return nil
|
||||
return make(map[int64]float64)
|
||||
}
|
||||
|
||||
collectionsMaxDelay := make(map[int64]time.Duration)
|
||||
|
@ -526,7 +526,7 @@ func (q *QuotaCenter) getTimeTickDelayFactor(ts Timestamp) map[int64]float64 {
|
|||
func (q *QuotaCenter) getMemoryFactor() map[int64]float64 {
|
||||
log := log.Ctx(context.Background()).WithRateGroup("rootcoord.QuotaCenter", 1.0, 60.0)
|
||||
if !Params.QuotaConfig.MemProtectionEnabled.GetAsBool() {
|
||||
return nil
|
||||
return make(map[int64]float64)
|
||||
}
|
||||
|
||||
dataNodeMemoryLowWaterLevel := Params.QuotaConfig.DataNodeMemoryLowWaterLevel.GetAsFloat()
|
||||
|
|
|
@ -320,7 +320,7 @@ func TestQuotaCenter(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
// force deny
|
||||
forceBak := Params.QuotaConfig.ForceDenyWriting
|
||||
forceBak := Params.QuotaConfig.ForceDenyWriting.GetValue()
|
||||
paramtable.Get().Save(Params.QuotaConfig.ForceDenyWriting.Key, "true")
|
||||
quotaCenter.writableCollections = []int64{1, 2, 3}
|
||||
quotaCenter.resetAllCurrentRates()
|
||||
|
@ -330,7 +330,22 @@ func TestQuotaCenter(t *testing.T) {
|
|||
assert.Equal(t, Limit(0), quotaCenter.currentRates[collection][internalpb.RateType_DMLInsert])
|
||||
assert.Equal(t, Limit(0), quotaCenter.currentRates[collection][internalpb.RateType_DMLDelete])
|
||||
}
|
||||
Params.QuotaConfig.ForceDenyWriting = forceBak
|
||||
paramtable.Get().Save(Params.QuotaConfig.ForceDenyWriting.Key, forceBak)
|
||||
|
||||
// disable tt delay protection
|
||||
disableTtBak := Params.QuotaConfig.TtProtectionEnabled.GetValue()
|
||||
paramtable.Get().Save(Params.QuotaConfig.TtProtectionEnabled.Key, "false")
|
||||
quotaCenter.resetAllCurrentRates()
|
||||
quotaCenter.queryNodeMetrics = make(map[UniqueID]*metricsinfo.QueryNodeQuotaMetrics)
|
||||
quotaCenter.queryNodeMetrics[0] = &metricsinfo.QueryNodeQuotaMetrics{
|
||||
Hms: metricsinfo.HardwareMetrics{
|
||||
Memory: 100,
|
||||
MemoryUsage: 100,
|
||||
},
|
||||
Effect: metricsinfo.NodeEffect{CollectionIDs: []int64{1, 2, 3}},
|
||||
}
|
||||
err = quotaCenter.calculateWriteRates()
|
||||
paramtable.Get().Save(Params.QuotaConfig.TtProtectionEnabled.Key, disableTtBak)
|
||||
})
|
||||
|
||||
t.Run("test MemoryFactor factors", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue