Skip to content

Commit d450f79

Browse files
timvaillancourttanjinx
authored andcommitted
vtorc: allow recoveries to be disabled from startup (vitessio#18005)
Signed-off-by: Tim Vaillancourt <[email protected]>
1 parent 8b452fb commit d450f79

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

go/flags/endtoend/vtorc.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ vtorc \
1616

1717
Flags:
1818
--allow-emergency-reparent Whether VTOrc should be allowed to run emergency reparent operation when it detects a dead primary (default true)
19+
--allow-recovery Whether VTOrc should be allowed to run recovery actions (default true)
1920
--alsologtostderr log to standard error as well as files
2021
--audit-file-location string File location where the audit logs are to be stored
2122
--audit-purge-duration duration Duration for which audit logs are held before being purged. Should be in multiples of days (default 168h0m0s)

go/vt/vtorc/config/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,15 @@ var (
192192
},
193193
)
194194

195+
allowRecovery = viperutil.Configure(
196+
"allow-recovery",
197+
viperutil.Options[bool]{
198+
FlagName: "allow-recovery",
199+
Default: true,
200+
Dynamic: true,
201+
},
202+
)
203+
195204
convertTabletsWithErrantGTIDs = viperutil.Configure(
196205
"change-tablets-with-errant-gtid-to-drained",
197206
viperutil.Options[bool]{
@@ -234,6 +243,7 @@ func registerFlags(fs *pflag.FlagSet) {
234243
fs.Duration("topo-information-refresh-duration", topoInformationRefreshDuration.Default(), "Timer duration on which VTOrc refreshes the keyspace and vttablet records from the topology server")
235244
fs.Duration("recovery-poll-duration", recoveryPollDuration.Default(), "Timer duration on which VTOrc polls its database to run a recovery")
236245
fs.Bool("allow-emergency-reparent", ersEnabled.Default(), "Whether VTOrc should be allowed to run emergency reparent operation when it detects a dead primary")
246+
fs.Bool("allow-recovery", allowRecovery.Default(), "Whether VTOrc should be allowed to run recovery actions")
237247
fs.Bool("change-tablets-with-errant-gtid-to-drained", convertTabletsWithErrantGTIDs.Default(), "Whether VTOrc should be changing the type of tablets with errant GTIDs to DRAINED")
238248
fs.Bool("enable-primary-disk-stalled-recovery", enablePrimaryDiskStalledRecovery.Default(), "Whether VTOrc should detect a stalled disk on the primary and failover")
239249

@@ -255,6 +265,7 @@ func registerFlags(fs *pflag.FlagSet) {
255265
topoInformationRefreshDuration,
256266
recoveryPollDuration,
257267
ersEnabled,
268+
allowRecovery,
258269
convertTabletsWithErrantGTIDs,
259270
enablePrimaryDiskStalledRecovery,
260271
)
@@ -380,6 +391,11 @@ func SetERSEnabled(val bool) {
380391
ersEnabled.Set(val)
381392
}
382393

394+
// GetAllowRecovery is a getter function.
395+
func GetAllowRecovery() bool {
396+
return allowRecovery.Get()
397+
}
398+
383399
// ConvertTabletWithErrantGTIDs reports whether VTOrc is allowed to change the tablet type of tablets with errant GTIDs to DRAINED.
384400
func ConvertTabletWithErrantGTIDs() bool {
385401
return convertTabletsWithErrantGTIDs.Get()

go/vt/vtorc/logic/vtorc.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ func ContinuousDiscovery() {
274274
log.Infof("continuous discovery: setting up")
275275
recentDiscoveryOperationKeys = cache.New(config.GetInstancePollTime(), time.Second)
276276

277+
if !config.GetAllowRecovery() {
278+
log.Info("--allow-recovery is set to 'false', disabling recovery actions")
279+
if err := DisableRecovery(); err != nil {
280+
log.Errorf("failed to disable recoveries: %+v", err)
281+
return
282+
}
283+
}
284+
277285
go handleDiscoveryRequests()
278286

279287
healthTick := time.Tick(config.HealthPollSeconds * time.Second)

0 commit comments

Comments
 (0)