Fix Discord Link RoleSyncManager thread leak#6512
Open
JRoy wants to merge 1 commit intoEssentialsX:2.xfrom
Open
Fix Discord Link RoleSyncManager thread leak#6512JRoy wants to merge 1 commit intoEssentialsX:2.xfrom
JRoy wants to merge 1 commit intoEssentialsX:2.xfrom
Conversation
mdcfe
reviewed
Apr 12, 2026
EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/rolesync/RoleSyncManager.java
Show resolved
Hide resolved
b5944db to
20b0fa4
Compare
Two issues causing unbounded thread growth: 1. The repeating sync task was never cancelled on plugin disable, leaking the timer itself. 2. Each sync() call spawns an async task that calls acquireUninterruptibly() on a 5-permit semaphore. The timer fires up to 50 sync calls per cycle, so 45 threads block indefinitely waiting for permits. Before they drain, the next cycle spawns 50 more. Threads accumulate until OOM. Fix: cancel the task on disable, and replace acquireUninterruptibly() with tryAcquire(5s timeout) in both sync() and unSync() so threads don't block indefinitely — skipped syncs retry on the next cycle. Fixes EssentialsX#6381
20b0fa4 to
a036a0a
Compare
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.
Two issues causing unbounded thread growth:
The repeating sync task was never cancelled on plugin disable,
leaking the timer itself.
Each sync() call spawns an async task that calls
acquireUninterruptibly() on a 5-permit semaphore. The timer fires
up to 50 sync calls per cycle, so 45 threads block indefinitely
waiting for permits. Before they drain, the next cycle spawns 50
more. Threads accumulate until OOM.
Fix: cancel the task on disable, and replace acquireUninterruptibly()
with tryAcquire(5s timeout) in both sync() and unSync() so threads
don't block indefinitely — skipped syncs retry on the next cycle.
Fixes #6381