Skip to content

Commit

Permalink
Multi-metrics throttler post v21 cleanup: remove unthrottled entry fr…
Browse files Browse the repository at this point in the history
…om topo (#17283)

Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach authored Dec 9, 2024
1 parent 250148e commit cb66920
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func TestThrottleViaApplySchema(t *testing.T) {
require.NotNil(t, keyspace.Keyspace.ThrottlerConfig.ThrottledApps)
// ThrottledApps will actually be empty at this point, but more specifically we want to see that "online-ddl" is not there.
appRule, ok := keyspace.Keyspace.ThrottlerConfig.ThrottledApps[throttlerapp.OnlineDDLName.String()]
assert.True(t, ok, "app rule: %v", appRule)
assert.False(t, ok, "app rule: %v", appRule)
})
}

Expand Down
14 changes: 6 additions & 8 deletions go/vt/schemamanager/tablet_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,12 @@ func (exec *TabletExecutor) executeAlterMigrationThrottle(ctx context.Context, a
throttlerConfig.ThrottledApps = make(map[string]*topodatapb.ThrottledAppRule)
}
if req.ThrottledApp != nil && req.ThrottledApp.Name != "" {
// TODO(shlomi) in v22: replace the following line with the commented out block
throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
// timeNow := time.Now()
// if protoutil.TimeFromProto(req.ThrottledApp.ExpiresAt).After(timeNow) {
// throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
// } else {
// delete(throttlerConfig.ThrottledApps, req.ThrottledApp.Name)
// }
timeNow := time.Now()
if protoutil.TimeFromProto(req.ThrottledApp.ExpiresAt).After(timeNow) {
throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
} else {
delete(throttlerConfig.ThrottledApps, req.ThrottledApp.Name)
}
}

return throttlerConfig
Expand Down
14 changes: 6 additions & 8 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2098,14 +2098,12 @@ func (s *VtctldServer) UpdateThrottlerConfig(ctx context.Context, req *vtctldata
throttlerConfig.CheckAsCheckSelf = false
}
if req.ThrottledApp != nil && req.ThrottledApp.Name != "" {
// TODO(shlomi) in v22: replace the following line with the commented out block
throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
// timeNow := time.Now()
// if protoutil.TimeFromProto(req.ThrottledApp.ExpiresAt).After(timeNow) {
// throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
// } else {
// delete(throttlerConfig.ThrottledApps, req.ThrottledApp.Name)
// }
timeNow := time.Now()
if protoutil.TimeFromProto(req.ThrottledApp.ExpiresAt).After(timeNow) {
throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
} else {
delete(throttlerConfig.ThrottledApps, req.ThrottledApp.Name)
}
}
return throttlerConfig
}
Expand Down
15 changes: 7 additions & 8 deletions go/vt/vtgate/executorcontext/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/mysql/config"
"vitess.io/vitess/go/mysql/sqlerror"
"vitess.io/vitess/go/protoutil"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/callerid"
"vitess.io/vitess/go/vt/discovery"
Expand Down Expand Up @@ -1439,14 +1440,12 @@ func (vc *VCursorImpl) ThrottleApp(ctx context.Context, throttledAppRule *topoda
throttlerConfig.ThrottledApps = make(map[string]*topodatapb.ThrottledAppRule)
}
if req.ThrottledApp != nil && req.ThrottledApp.Name != "" {
// TODO(shlomi) in v22: replace the following line with the commented out block
throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
// timeNow := time.Now()
// if protoutil.TimeFromProto(req.ThrottledApp.ExpiresAt).After(timeNow) {
// throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
// } else {
// delete(throttlerConfig.ThrottledApps, req.ThrottledApp.Name)
// }
timeNow := time.Now()
if protoutil.TimeFromProto(req.ThrottledApp.ExpiresAt).After(timeNow) {
throttlerConfig.ThrottledApps[req.ThrottledApp.Name] = req.ThrottledApp
} else {
delete(throttlerConfig.ThrottledApps, req.ThrottledApp.Name)
}
}
return throttlerConfig
}
Expand Down

0 comments on commit cb66920

Please sign in to comment.