fix(retry): guard RetryBudget mutable config against data race

UpdateConfig writes tokensPerSecond/maxTokens/enabled as plain fields while
the refill goroutine and AllowRetry readers touch them concurrently. Guard
all reads/writes of the mutable config with an RWMutex.

Adds TestRetryBudget_ConcurrentUpdateConfig, which races UpdateConfig
against AllowRetry/GetStats and is verified clean under -race.

Also drop the package-level min() that shadowed the Go 1.25 builtin.
This commit is contained in:
2026-08-13 01:20:55 +01:00
parent 6fd8f99b7e
commit 963f72ff17
3 changed files with 80 additions and 15 deletions
-7
View File
@@ -234,10 +234,3 @@ func InitializeRequestCoalescer(enabled bool, logger *libpack_logger.Logger, mon
func GetRequestCoalescer() *RequestCoalescer {
return requestCoalescer
}
func min(a, b int) int {
if a < b {
return a
}
return b
}