Skip to content

Conversation

forkfury
Copy link

Fix race condition in ThrottleController.Update by changing RLock to Lock

The Update method was using RLock to read strategy reference, then calling
strategy.Update() without holding the lock. This created a race condition
where SetStrategy could change the strategy between reading the reference
and using it, leading to inconsistent throttling behavior.

Using Lock instead of RLock ensures the entire Update operation is atomic,
preventing SetStrategy from modifying the strategy while Update executes.
This guarantees thread safety when controller type is changed at runtime.

@forkfury forkfury requested review from a team as code owners September 16, 2025 16:58
@forkfury forkfury requested a review from serpixel September 16, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant