Make Shutdown Idempotent#73
Merged
Merged
Conversation
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>
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 |
bastelfreak
approved these changes
Jul 2, 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.
Short description
This changeset updates the Instance Pool and Multithreaded Pools such that calling their
shutdownmethods more than once no longer results in an un-handledInterruptedException. 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:
Signed-off-byannotation to each of my commitsGenerated-byorAssisted-byannotations to each of my commits created with the help of an AI agent