Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1057.
Throttle callbacks currently run while holding the same mutex that
resetacquires, so a callback that resets its throttle deadlocks. The same lock also blocks an unrelated key behind a slow callback.Reserve the per-key count and start the window timer under the state lock, then release the lock before invoking callbacks. Calls remain synchronous, and callbacks within one call keep their order. As documented in the updated comment, the window now starts before the first callback and accepted concurrent calls can overlap; callbacks are no longer serialized by the internal state mutex.
Regression coverage checks callback reset with count limits of 1 and 3, same-key callback reentry, another key progressing while a callback is blocked, and 100 concurrent calls respecting the count limit. The final tests fail on unchanged main for reset/reentry/cross-key deadlocks and pass with the change.
Verified on macOS arm64 / Go 1.27.3:
go test -race ./...(all root-module packages, including iterator/mutable/parallel packages).go vet ./....golangci-lint run --new-from-rev 6f5a63a: 0 new issues.git diff --check.Full golangci-lint 2.15.0 reports 64 existing unused
//nolint:revivedirectives in benchmark files; an unchanged base worktree reports the same 64 findings. No lint configuration was changed. The separate experimental SIMD module and other operating systems were not tested.Prepared with OpenAI Codex assistance; reproduction, implementation, and local checks were performed in this session.