Skip to content

Fix Discord Link RoleSyncManager thread leak#6512

Open
JRoy wants to merge 1 commit intoEssentialsX:2.xfrom
JRoy:fix/6381-discord-link-thread-leak
Open

Fix Discord Link RoleSyncManager thread leak#6512
JRoy wants to merge 1 commit intoEssentialsX:2.xfrom
JRoy:fix/6381-discord-link-thread-leak

Conversation

@JRoy
Copy link
Copy Markdown
Member

@JRoy JRoy commented Apr 12, 2026

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 #6381

@JRoy JRoy force-pushed the fix/6381-discord-link-thread-leak branch from b5944db to 20b0fa4 Compare April 12, 2026 21:11
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
@JRoy JRoy force-pushed the fix/6381-discord-link-thread-leak branch from 20b0fa4 to a036a0a Compare April 12, 2026 21:11
@JRoy JRoy requested a review from mdcfe April 12, 2026 21:12
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.

EssentalsX Discord Link leaking threads

2 participants