Fix BrokerPool shutdown hang causing CI timeouts#6167
Merged
line-o merged 1 commit intoeXist-db:developfrom Mar 24, 2026
Merged
Fix BrokerPool shutdown hang causing CI timeouts#6167line-o merged 1 commit intoeXist-db:developfrom
line-o merged 1 commit intoeXist-db:developfrom
Conversation
Three targeted fixes prevent the forked JVM from hanging after BrokerPool.shutdown() completes: 1. StatusReporter threads are now daemon threads. The startup and shutdown status reporter threads are monitoring-only and must not prevent JVM exit. Added newInstanceDaemonThread() to ThreadUtils. 2. Four wait loops in BrokerPool that swallowed InterruptedException and used unbounded wait() now have 1-second poll timeouts, isShuttingDown() checks, and proper interrupt handling: - get() service mode wait: breaks on shutdown or interrupt - get() broker availability wait: throws EXistException on shutdown - enterServiceMode() wait: breaks on shutdown or interrupt - shutdown() active brokers wait: re-sets interrupt flag and breaks 3. At end of shutdown, instanceThreadGroup.interrupt() wakes any lingering threads in the instance's thread group. Previously, 4 test classes required exclusion or timeout workarounds (DeadlockIT, RemoveCollectionIT, CollectionLocksTest, MoveResourceTest). Now all complete cleanly: 6533 unit tests + 9 integration tests, 0 failures, clean JVM exit. Affects PRs with CI timeout workarounds: eXist-db#6112, eXist-db#6139, eXist-db#6138 Related: eXist-db#3685 (FragmentsTest deadlock) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
duncdrum
approved these changes
Mar 24, 2026
line-o
approved these changes
Mar 24, 2026
Member
line-o
left a comment
There was a problem hiding this comment.
LGTM
side note: the formatting is slightly off in the if-condition
joewiz
added a commit
to joewiz/exist
that referenced
this pull request
Mar 24, 2026
Pick up BrokerPool shutdown fix (eXist-db#6167) and @line-o's function type checking refactoring. Resolved 11 merge conflicts. Known regression: 12 XQSuite map ordering tests fail (QT4-only, not in QT3/XQ31). @line-o's MapType refactoring removed the keyOrder tracking that our XQ4 ordered map implementation used. The ordered map support needs to be re-implemented on top of the new MapType API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 25, 2026
joewiz
added a commit
to joewiz/exist
that referenced
this pull request
Mar 25, 2026
BlobStoreImpl's PersistentWriter and BlobVacuum threads were created as non-daemon threads, which prevents JVM exit if BrokerPool shutdown fails to join them cleanly. This caused ~20% of CI runs to hang indefinitely after tests completed. Mark both threads as daemon threads so they cannot block JVM shutdown. The threads still participate in normal shutdown via poison pill (PersistentWriter) and interrupt (BlobVacuum), but now the JVM can exit even if those shutdown paths fail. Also add a forkedProcessExitTimeoutInSeconds safety net to the surefire configuration, and a regression test that verifies no non-daemon eXist threads survive BrokerPool shutdown. Follow-up to PR eXist-db#6167 which fixed the same issue for StatusReporter. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 25, 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.
Summary
Fixes the root cause behind CI timeout failures across multiple PRs. The forked JVM hangs after
BrokerPool.shutdown()completes because non-daemon threads and unbounded wait loops prevent JVM exit.Three-part fix
Daemon StatusReporter threads — The
startup-status-reporterandshutdown-status-reporterthreads are monitoring-only and must not prevent JVM exit. AddednewInstanceDaemonThread()toThreadUtilsand used it for both StatusReporter threads.Bounded wait loops with shutdown checks — Four wait loops in
BrokerPoolswallowedInterruptedExceptionwith//nothing to be done!comments and used unboundedwait(). Now all four have 1-second poll timeouts,isShuttingDown()checks, and proper interrupt handling:get()service mode wait — breaks on shutdown or interruptget()broker availability wait — throwsEXistExceptionon shutdown/interruptenterServiceMode()wait — breaks on shutdown or interruptshutdown()active brokers wait — re-sets interrupt flag and breaksThread group interrupt on shutdown — At the end of shutdown,
instanceThreadGroup.interrupt()wakes any lingering threads so they can exit cleanly.Before/after
Previously, 4 test classes required exclusion or timeout workarounds (DeadlockIT, RemoveCollectionIT, CollectionLocksTest, MoveResourceTest). Now all 4 complete cleanly: 6533 unit tests + 9 integration tests, 0 failures, clean JVM exit in ~12 minutes total.
Related
Test plan
mvn test -pl exist-core— 6533 tests, 0 failures, BUILD SUCCESS, clean exit (4 min)mvn verify -pl exist-coreintegration tests — 9 tests including previously-excluded DeadlockIT and RemoveCollectionIT, 0 failures, BUILD SUCCESS, clean exit (8 min)🤖 Generated with Claude Code