Skip to content

ARTEMIS-6162 Only start lock coordinators once the broker is activated#6590

Open
MyLuk wants to merge 2 commits into
apache:mainfrom
MyLuk:ARTEMIS-6162
Open

ARTEMIS-6162 Only start lock coordinators once the broker is activated#6590
MyLuk wants to merge 2 commits into
apache:mainfrom
MyLuk:ARTEMIS-6162

Conversation

@MyLuk

@MyLuk MyLuk commented Jul 21, 2026

Copy link
Copy Markdown

Two commits, one per JIRA:

ARTEMIS-6162 - internalStart() started every configured lock coordinator right away, whatever the HA role of the node, so a passive backup contended for the lock along with the active primary. A passive backup that wins the lock holds it while none of its acceptors or broker connections exist yet, so the elements bound to that coordinator are down on every node of the group. And with brokers in different data centers sharing a lock, the backup of a failed primary needs a few seconds to activate while remote brokers keep polling every check-period, so the lock usually lands on a remote broker rather than on the backup taking over.

The coordinators are still created in internalStart(), since acceptors and broker connections look them up by name while being created, but polling now starts in completeActivation(), right before the acceptors are started.

ARTEMIS-6163 - even then, all active brokers still race for the lock, and which of them may take a lock over on its own is a deployment decision. Adds an auto-start attribute on lock-coordinator (default true, no behaviour change) plus startLockCoordinator/stopLockCoordinator management operations, both audited, so a standby data center can be configured with auto-start=false and handed the lock only when somebody decides so.

Both behaviours were suggested by @clebertsuconic on the users list ("Artemis Cluster with HA and with Mesh Mirror", May 2026).

Tests: LockCoordinatorHaActivationTest (replicated pair, the passive backup stays out of the lock and takes it over once the primary is gone) and LockCoordinatorAutoStartManagementTest (full start/stop cycle through management on an acceptor bound to an auto-start=false coordinator), both failing without the respective fix, plus a unit test for the flag and parser coverage. The first commit compiles and its test passes on its own.

MyLuk added 2 commits July 21, 2026 08:16
ActiveMQServerImpl.internalStart() started every configured lock
coordinator right away, regardless of the HA role of the node, so a
passive backup contended for the lock along with the active primary.

Two things go wrong with that. A passive backup that wins the lock
holds it while none of its acceptors or broker connections exist yet,
so the elements bound to that coordinator are down on every node of
the group. And when brokers in different data centers share a lock,
the backup of a failed primary needs a few seconds to activate while
the remote brokers keep polling every check-period, so the lock
usually lands on a remote broker rather than on the backup that is
taking over.

Split the creation from the start. The coordinators are still created
in internalStart(), since acceptors and broker connections look them
up by name while they are being created, but polling for the lock now
starts in completeActivation(), the single point every activation
goes through, right before the acceptors are started. Only a node
that actually became active contends for the lock.

Added LockCoordinatorHaActivationTest: a replicated pair sharing one
coordinator. The passive backup keeps its coordinator stopped while
the primary holds the lock, and takes the lock over once the primary
is gone. Without the fix the backup is polling for the lock while
still passive and the test fails.
…nators

Now that lock coordinators only start once a broker is activated, the
brokers that are active still all race for the lock. When a primary
fails, a broker in a standby data center can grab the lock before the
backup of that primary has finished activating, so the group comes
back in the wrong place. Which brokers may take a lock over on their
own is a deployment decision, not something a broker can work out by
itself.

Added an auto-start attribute on lock-coordinator, defaulting to true
so nothing changes for existing configurations. With auto-start=false
the coordinator is created and visible in management, but it never
polls for the lock on its own, so it stays out of the race until
somebody decides otherwise.

To make that decision possible, ActiveMQServerControl now exposes
startLockCoordinator and stopLockCoordinator next to the existing
listLockCoordinatorsAsJSON, both audited. Starting an already started
coordinator does nothing, stopping one that holds the lock releases
it and pauses whatever is bound to it, and an unknown name is
rejected. A coordinator can be started again after it was stopped, so
a data center can be handed the lock and handed it back.

Added LockCoordinatorAutoStartManagementTest for the whole cycle on an
acceptor bound to an auto-start=false coordinator, a unit test for the
flag itself and parser coverage for the new attribute.
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.

1 participant