Skip to content

Commit

Permalink
Remove expired/unthrottled rules from topo rather than set them to 0 …
Browse files Browse the repository at this point in the history
…expiration duration

Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Nov 25, 2024
1 parent 0b51839 commit e3fda9a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
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 @@ -2096,14 +2096,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/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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 @@ -1343,14 +1344,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 e3fda9a

Please sign in to comment.