Skip to content

Commit

Permalink
2 flags
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 20, 2025
1 parent 42e83db commit 809d310
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
3 changes: 2 additions & 1 deletion go/flags/endtoend/vtorc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Flags:
--audit-purge-duration duration Duration for which audit logs are held before being purged. Should be in multiples of days (default 168h0m0s)
--audit-to-backend Whether to store the audit log in the VTOrc database
--audit-to-syslog Whether to store the audit log in the syslog
--backend-db-concurrency int Maximum concurrency for reads and writes to the backend (separately) (default 20)
--backend-read-concurrency int Maximum concurrency for reads to the backend (default 20)
--backend-write-concurrency int Maximum concurrency for writes to the backend (default 20)
--bind-address string Bind address for the server. If empty, the server will listen on all available unicast and anycast IP addresses of the local system.
--catch-sigpipe catch and ignore SIGPIPE on stdout and stderr if specified
--change-tablets-with-errant-gtid-to-drained Whether VTOrc should be changing the type of tablets with errant GTIDs to DRAINED
Expand Down
32 changes: 24 additions & 8 deletions go/vt/vtorc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,19 @@ var (
},
)

backendDBConcurrency = viperutil.Configure(
"backend-db-concurrency",
backendReadConcurrency = viperutil.Configure(
"backend-read-concurrency",
viperutil.Options[int64]{
FlagName: "backend-db-concurrency",
FlagName: "backend-read-concurrency",
Default: 20,
Dynamic: true,
},
)

backendWriteConcurrency = viperutil.Configure(
"backend-write-concurrency",
viperutil.Options[int64]{
FlagName: "backend-write-concurrency",
Default: 20,
Dynamic: true,
},
Expand Down Expand Up @@ -208,7 +217,8 @@ func registerFlags(fs *pflag.FlagSet) {
fs.Bool("audit-to-backend", auditToBackend.Default(), "Whether to store the audit log in the VTOrc database")
fs.Bool("audit-to-syslog", auditToSyslog.Default(), "Whether to store the audit log in the syslog")
fs.Duration("audit-purge-duration", auditPurgeDuration.Default(), "Duration for which audit logs are held before being purged. Should be in multiples of days")
fs.Int64("backend-db-concurrency", backendDBConcurrency.Default(), "Maximum concurrency for reads and writes to the backend (separately)")
fs.Int64("backend-read-concurrency", backendReadConcurrency.Default(), "Maximum concurrency for reads to the backend")
fs.Int64("backend-write-concurrency", backendWriteConcurrency.Default(), "Maximum concurrency for writes to the backend")
fs.Bool("prevent-cross-cell-failover", preventCrossCellFailover.Default(), "Prevent VTOrc from promoting a primary in a different cell than the current primary in case of a failover")
fs.Duration("wait-replicas-timeout", waitReplicasTimeout.Default(), "Duration for which to wait for replica's to respond when issuing RPCs")
fs.Duration("tolerable-replication-lag", tolerableReplicationLag.Default(), "Amount of replication lag that is considered acceptable for a tablet to be eligible for promotion when Vitess makes the choice of a new primary in PRS")
Expand All @@ -228,7 +238,8 @@ func registerFlags(fs *pflag.FlagSet) {
auditToBackend,
auditToSyslog,
auditPurgeDuration,
backendDBConcurrency,
backendReadConcurrency,
backendWriteConcurrency,
waitReplicasTimeout,
tolerableReplicationLag,
topoInformationRefreshDuration,
Expand Down Expand Up @@ -314,9 +325,14 @@ func SetAuditPurgeDays(days int64) {
auditPurgeDuration.Set(time.Duration(days) * 24 * time.Hour)
}

// GetBackendDBConcurrency returns the max backend db concurrency.
func GetBackendDBConcurrency() int64 {
return backendDBConcurrency.Get()
// GetBackendReadConcurrency returns the max backend read concurrency.
func GetBackendReadConcurrency() int64 {
return backendReadConcurrency.Get()
}

// GetBackendWriteConcurrency returns the max backend write concurrency.
func GetBackendWriteConcurrency() int64 {
return backendWriteConcurrency.Get()
}

// GetWaitReplicasTimeout is a getter function.
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtorc/inst/instance_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ import (
const maxBackendOpTime = time.Second * 5

var (
instanceReadSem = semaphore.NewWeighted(config.GetBackendDBConcurrency())
instanceWriteSem = semaphore.NewWeighted(config.GetBackendDBConcurrency())
instanceReadSem = semaphore.NewWeighted(config.GetBackendReadConcurrency())
instanceWriteSem = semaphore.NewWeighted(config.GetBackendWriteConcurrency())
)

var forgetAliases *cache.Cache
Expand Down

0 comments on commit 809d310

Please sign in to comment.