fix: the system rejects all queries and never recovers if enabled read rate limit (#30061)

fix #30060

Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
yah01 2024-01-17 23:30:55 +08:00 committed by GitHub
parent 91aa81b4d7
commit 0d4e781f69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 15 deletions

View File

@ -25,7 +25,7 @@ type counter struct {
values map[string]int64
}
func (c *counter) Inc(label string, value int64) {
func (c *counter) Add(label string, value int64) {
c.Lock()
defer c.Unlock()
@ -38,17 +38,12 @@ func (c *counter) Inc(label string, value int64) {
}
}
func (c *counter) Dec(label string, value int64) {
c.Lock()
defer c.Unlock()
func (c *counter) Inc(label string) {
c.Add(label, 1)
}
v, ok := c.values[label]
if !ok {
c.values[label] = -value
} else {
v -= value
c.values[label] = v
}
func (c *counter) Dec(label string) {
c.Add(label, -1)
}
func (c *counter) Set(label string, value int64) {

View File

@ -39,7 +39,7 @@ func (suite *CounterTestSuite) TestBasic() {
suite.Equal(int64(0), value)
// get after inc
suite.counter.Inc(suite.label, 3)
suite.counter.Add(suite.label, 3)
value = suite.counter.Get(suite.label)
suite.Equal(int64(3), value)
@ -49,7 +49,7 @@ func (suite *CounterTestSuite) TestBasic() {
suite.Equal(int64(0), value)
// get after dec
suite.counter.Dec(suite.label, 3)
suite.counter.Add(suite.label, -3)
value = suite.counter.Get(suite.label)
suite.Equal(int64(-3), value)

View File

@ -232,13 +232,13 @@ func (s *scheduler) exec() {
s.getPool(t).Submit(func() (any, error) {
// Update concurrency metric and notify task done.
metrics.QueryNodeReadTaskConcurrency.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Inc()
collector.Counter.Inc(metricsinfo.ExecuteQueueType, 1)
collector.Counter.Inc(metricsinfo.ExecuteQueueType)
err := t.Execute()
// Update all metric after task finished.
metrics.QueryNodeReadTaskConcurrency.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Dec()
collector.Counter.Dec(metricsinfo.ExecuteQueueType, -1)
collector.Counter.Dec(metricsinfo.ExecuteQueueType)
// Notify task done.
t.Done(err)