StartCommand: keep waiting past the default start timeout unless a start exception was recorded - #2554
Open
jbonofre wants to merge 1 commit into
Open
Conversation
… exception was actually recorded BrokerService.DEFAULT_START_TIMEOUT is 10 minutes, and StartCommand called broker.waitUntilStarted() with that timeout, throwing (and exiting the process) whenever it returned false. Before startAsync existed this was never an issue, since start() itself blocked until the broker became master, so waitUntilStarted() returned almost immediately either way. With startAsync=true, start() returns right away, and a slave broker can legitimately wait on the lock far longer than 10 minutes - that's expected, not a failure. When the timeout hit, waitUntilStarted() returned false with no start exception set, and StartCommand treated that as a startup failure and exited the process with nothing logged. StartCommand now keeps calling waitUntilStarted() as long as broker.getStartException() is null, and only throws/exits once an actual start exception has been recorded. BrokerService.stop() always records a start exception before it ever marks the broker stopped, so this cannot spin: a real stop or start failure still surfaces immediately. Fixes apache#2552
cshannon
requested changes
Sep 9, 2026
|
|
||
| if (!broker.waitUntilStarted()) { | ||
| throw new Exception(broker.getStartException()); | ||
| while (!broker.waitUntilStarted()) { |
Contributor
There was a problem hiding this comment.
Just like my comment on the other PR, we should probably do an broker.isSlave() check here. The exception should be set, but in case something gets broken in the future this would add an extra check just to ensure we always fail for a primary/active broker just like today if it returns false.
Maybe:
while (!broker.waitUntilStarted()) {
if (broker.getStartException() != null || !broker.isSlave()) {
throw new Exception(broker.getStartException());
}
}
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
./activemq startwithstartAsync=true, running as a slave, disappeared after roughly 10 minutes with nothing logged.BrokerService.DEFAULT_START_TIMEOUTis 10 minutes, andStartCommandcalledbroker.waitUntilStarted()with that timeout, throwing (and exiting the process) whenever it returnedfalse. BeforestartAsyncexisted this was harmless, sincestart()itself blocked until the broker became master. WithstartAsync=true,start()returns immediately, and a slave can legitimately wait on the lock far longer than 10 minutes.StartCommandnow loops onwaitUntilStarted(), only throwing/exiting oncebroker.getStartException()is actually non-null. This can't spin indefinitely:BrokerService.stop()always records a start exception (BrokerStoppedException) before it ever marks the broker as stopped, so a real stop or startup failure still surfaces immediately.Test plan
mvn -pl activemq-console -am compilesucceedsstartAsync=trueand confirm the process stays alive past 10 minutes while waiting on the lock, and exits promptly with a logged error on an actual startup failureFixes #2552