Fix connection throttle cleanup wiping the whole tracker#14011
Open
gunjanjaswal wants to merge 1 commit into
Open
Fix connection throttle cleanup wiping the whole tracker#14011gunjanjaswal wants to merge 1 commit into
gunjanjaswal wants to merge 1 commit into
Conversation
The stale-entry cleanup compared a stored timestamp directly against the throttle duration (`time > connectionThrottle`). A real epoch timestamp is always far greater than the configured duration (default 4000ms), so the predicate matched every entry and cleared the entire throttleTracker every ~200 connections. Between cleanups a client could reconnect around the cycle and dodge the per-IP throttle. Compare elapsed time instead (`currentTime - time > connectionThrottle`), matching the check used a few lines above where the same `currentTime` is already computed. Fixes PaperMC#13984.
electronicboy
approved these changes
Jun 30, 2026
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.
Problem
The connection throttle cleanup in
ServerHandshakePacketListenerImplwipes the entirethrottleTrackerevery ~200 connections. The cleanup predicate compares a stored timestamp against the throttle duration:timeis an epoch-millisecond timestamp (~1.7e12);connectionThrottleis a duration (default 4000ms). Sotime > connectionThrottleis always true and every entry is removed. The check a few lines above already does it correctly:Within a cleanup cycle the per-IP throttle works, but every 200th connection clears the map, so a client can time reconnects around the cleanup and slip past the throttle.
Fix
Compare elapsed time, reusing the
currentTimealready computed in the same block:This is a content-only change to the existing added line in the patch, so it applies cleanly with no rebuildPatches churn.
Fixes #13984.