Skip to content

Commit

Permalink
add struct var
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
  • Loading branch information
timvaillancourt committed Feb 18, 2025
1 parent a2aca24 commit 9bde970
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions go/test/endtoend/vtorc/readtopologyinstance/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestReadTopologyInstanceBufferable(t *testing.T) {
}
servenv.ParseFlags("vtorc")
config.Config.AllowRecovery = true
config.Config.DiscoveryMaxConcurrency = 10
config.Config.RecoveryPeriodBlockSeconds = 1
config.Config.InstancePollSeconds = 1
config.MarkConfigurationLoaded()
Expand Down
41 changes: 21 additions & 20 deletions go/vt/vtorc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,24 @@ const (
)

var (
sqliteDataFile = "file::memory:?mode=memory&cache=shared"
instancePollTime = 5 * time.Second
snapshotTopologyInterval = 0 * time.Hour
reasonableReplicationLag = 10 * time.Second
auditFileLocation = ""
auditToBackend = false
auditToSyslog = false
auditPurgeDuration = 7 * 24 * time.Hour // Equivalent of 7 days
allowRecovery = true
recoveryPeriodBlockDuration = 30 * time.Second
preventCrossCellFailover = false
waitReplicasTimeout = 30 * time.Second
tolerableReplicationLag = 0 * time.Second
topoInformationRefreshDuration = 15 * time.Second
recoveryPollDuration = 1 * time.Second
ersEnabled = true
convertTabletsWithErrantGTIDs = false

DiscoveryMaxConcurrency uint = 300 // Number of goroutines doing hosts discovery
sqliteDataFile = "file::memory:?mode=memory&cache=shared"
instancePollTime = 5 * time.Second
snapshotTopologyInterval = 0 * time.Hour
reasonableReplicationLag = 10 * time.Second
auditFileLocation = ""
auditToBackend = false
auditToSyslog = false
auditPurgeDuration = 7 * 24 * time.Hour // Equivalent of 7 days
allowRecovery = true
recoveryPeriodBlockDuration = 30 * time.Second
preventCrossCellFailover = false
waitReplicasTimeout = 30 * time.Second
tolerableReplicationLag = 0 * time.Second
topoInformationRefreshDuration = 15 * time.Second
recoveryPollDuration = 1 * time.Second
ersEnabled = true
convertTabletsWithErrantGTIDs = false
discoveryMaxConcurrency uint = 300 // Number of goroutines doing hosts discovery
)

// RegisterFlags registers the flags required by VTOrc
Expand All @@ -87,7 +86,7 @@ func RegisterFlags(fs *pflag.FlagSet) {
fs.DurationVar(&recoveryPollDuration, "recovery-poll-duration", recoveryPollDuration, "Timer duration on which VTOrc polls its database to run a recovery")
fs.BoolVar(&ersEnabled, "allow-emergency-reparent", ersEnabled, "Whether VTOrc should be allowed to run emergency reparent operation when it detects a dead primary")
fs.BoolVar(&convertTabletsWithErrantGTIDs, "change-tablets-with-errant-gtid-to-drained", convertTabletsWithErrantGTIDs, "Whether VTOrc should be changing the type of tablets with errant GTIDs to DRAINED")
fs.UintVar(&DiscoveryMaxConcurrency, "discovery-max-concurrency", DiscoveryMaxConcurrency, "Number of goroutines dedicated to doing hosts discovery")
fs.UintVar(&discoveryMaxConcurrency, "discovery-max-concurrency", discoveryMaxConcurrency, "Number of goroutines dedicated to doing hosts discovery")
}

// Configuration makes for vtorc configuration input, which can be provided by user via JSON formatted file.
Expand All @@ -110,6 +109,7 @@ type Configuration struct {
TopoInformationRefreshSeconds int // Timer duration on which VTOrc refreshes the keyspace and vttablet records from the topo-server.
AllowRecovery bool // Allow recoveries.
RecoveryPollSeconds int // Timer duration on which VTOrc recovery analysis runs
DiscoveryMaxConcurrency uint // Number of goroutines dedicated to doing hosts discovery
}

// ToJSONString will marshal this configuration as JSON
Expand Down Expand Up @@ -141,6 +141,7 @@ func UpdateConfigValuesFromFlags() {
Config.TopoInformationRefreshSeconds = int(topoInformationRefreshDuration / time.Second)
Config.AllowRecovery = allowRecovery
Config.RecoveryPollSeconds = int(recoveryPollDuration / time.Second)
Config.DiscoveryMaxConcurrency = discoveryMaxConcurrency
}

// ERSEnabled reports whether VTOrc is allowed to run ERS or not.
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtorc/logic/vtorc.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func waitForLocksRelease() {
func handleDiscoveryRequests() {
discoveryQueue = discovery.CreateOrReturnQueue("DEFAULT")
// create a pool of discovery workers
for i := uint(0); i < config.DiscoveryMaxConcurrency; i++ {
for i := uint(0); i < config.Config.DiscoveryMaxConcurrency; i++ {
go func() {
for {
tabletAlias := discoveryQueue.Consume()
Expand Down

0 comments on commit 9bde970

Please sign in to comment.