Skip to content

Make Shutdown Idempotent#73

Merged
Sharpie merged 2 commits into
OpenVoxProject:mainfrom
Sharpie:idempotent-shutdown
Jul 2, 2026
Merged

Make Shutdown Idempotent#73
Sharpie merged 2 commits into
OpenVoxProject:mainfrom
Sharpie:idempotent-shutdown

Conversation

@Sharpie

@Sharpie Sharpie commented Jul 2, 2026

Copy link
Copy Markdown
Member

Short description

This changeset updates the Instance Pool and Multithreaded Pools such that calling their shutdown methods more than once no longer results in an un-handled InterruptedException. Having an idempotent shutdown eliminates log noise and makes it easier to focus on the cause of failures in tests or application startup sequences.

Checklist

I have:

Sharpie and others added 2 commits July 1, 2026 12:03
When an instance fails to initialize, add-instance's error handler clears
the pool and inserts a poison pill. If that happens while a concurrent
shutdown is draining the pool, borrow-all-jrubies' lock attempt is
interrupted with "Lock can't be granted because a pill has been
inserted", and that InterruptedException propagates uncaught out of
flush-pool-for-shutdown!, failing the TrapperKeeper stop sequence. The
same occurs if flush-pool-for-shutdown! is called again after a prior
shutdown already inserted a pill.

Catch InterruptedException in flush-pool-for-shutdown!: a pill already
present means the pool is already unusable, so ensure a shutdown pill is
in place and treat the flush as a completed no-op instead of raising.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Charlie Sharpsteen <charlie@overlookinfratech.com>
Prior to this change, the ReferencePool, used when `multithreaded: true`,
would throw an `InterruptedException` if the `shutdown` method was called
more than once. During shutdown, the pool is locked and all instances
are borrowed and then disposed of. The `InterruptedException` is raised
when attempting to lock a pool that has been poisoned by the shutdown
pill.

This commit fixes the issue by catching `InterrutedException` raised
from the initial lock attempt and treating that as a signal that the
pool is already shut down and there is no work to do.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Charlie Sharpsteen <charlie@overlookinfratech.com>
@Sharpie Sharpie added the bug Something isn't working label Jul 2, 2026
@Sharpie

Sharpie commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

This is the second half of a fix for random test failures that have been plaguing OpenVox Server. See OpenVoxProject/openvox-server#414

@Sharpie Sharpie merged commit c0fd17c into OpenVoxProject:main Jul 2, 2026
5 checks passed
@Sharpie Sharpie deleted the idempotent-shutdown branch July 2, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants