Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-metrics throttler post v21 cleanup: remove unthrottled entry from topo #17283

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading