Skip to content

Commit

Permalink
license: don't hit EnvOrDefaultInt64 in hot path
Browse files Browse the repository at this point in the history
Fixes cockroachdb#133088.

Release note: None
Epic: None
  • Loading branch information
tbg committed Oct 29, 2024
1 parent 987dd38 commit 089eb3c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/server/license/enforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,12 @@ func (e *Enforcer) getGracePeriodDuration(defaultAndMaxLength time.Duration) tim
return newLength
}

var maxOpenTxnsDuringThrottle = envutil.EnvOrDefaultInt64("COCKROACH_MAX_OPEN_TXNS_DURING_THROTTLE", defaultMaxOpenTransactions)

// getMaxOpenTransactions returns the number of open transactions allowed before
// throttling takes affect.
func (e *Enforcer) getMaxOpenTransactions() int64 {
newLimit := envutil.EnvOrDefaultInt64("COCKROACH_MAX_OPEN_TXNS_DURING_THROTTLE", defaultMaxOpenTransactions)
newLimit := maxOpenTxnsDuringThrottle
if tk := e.GetTestingKnobs(); tk != nil && tk.OverrideMaxOpenTransactions != nil {
newLimit = *tk.OverrideMaxOpenTransactions
}
Expand Down

0 comments on commit 089eb3c

Please sign in to comment.