Context
Follow-up to #4727 / PR #4739 (HA auto-acquire of never-seen databases). Code review noted that
ArcadeStateMachine now carries a fair amount of database reconcile orchestration on top of its
core Ratis StateMachine contract. This is a non-blocking code-health item, deferred out of #4739 to
avoid late churn on a converged PR.
Scope
Extract the reconcile orchestration into a dedicated DatabaseReconciler collaborator, leaving
ArcadeStateMachine focused on the Ratis state-machine contract. Candidates to move:
reconcileDatabasesFromLeader(...) and refreshExistingDatabases(...)
- the pure helpers
classifyReconcile(...), executeReconcilePlan(...), applyReconcileOutcome(...),
bumpFailureAndShouldRetry(...)
- the per-database state:
acquireStatuses and acquireFailureCounts (+ the AcquireStatus /
AcquireState / ReconcilePlan / ReconcileOutcome types and the getAcquireStatus /
getDatabasesWithAcquireState accessors used by GetClusterHandler / ClusterAlerts)
- the give-up constant
ACQUIRE_GIVE_UP_AFTER
Considerations
notifyInstallSnapshotFromLeader and notifyLeaderChanged would delegate to the collaborator
(the leader-change cleanup of LEADER_MISSING / FAILED statuses + failure counters).
- The unit tests in
ReconcilePlanTest reference ArcadeStateMachine.classifyReconcile /
executeReconcilePlan / applyReconcileOutcome directly; they would move to target the new class.
GetClusterHandler and ClusterAlerts call getAcquireStatus / getDatabasesWithAcquireState,
so the accessors must remain reachable (likely via the reconciler instance held by the state machine).
Pure refactor - no behavior change.
Context
Follow-up to #4727 / PR #4739 (HA auto-acquire of never-seen databases). Code review noted that
ArcadeStateMachinenow carries a fair amount of database reconcile orchestration on top of itscore Ratis
StateMachinecontract. This is a non-blocking code-health item, deferred out of #4739 toavoid late churn on a converged PR.
Scope
Extract the reconcile orchestration into a dedicated
DatabaseReconcilercollaborator, leavingArcadeStateMachinefocused on the Ratis state-machine contract. Candidates to move:reconcileDatabasesFromLeader(...)andrefreshExistingDatabases(...)classifyReconcile(...),executeReconcilePlan(...),applyReconcileOutcome(...),bumpFailureAndShouldRetry(...)acquireStatusesandacquireFailureCounts(+ theAcquireStatus/AcquireState/ReconcilePlan/ReconcileOutcometypes and thegetAcquireStatus/getDatabasesWithAcquireStateaccessors used byGetClusterHandler/ClusterAlerts)ACQUIRE_GIVE_UP_AFTERConsiderations
notifyInstallSnapshotFromLeaderandnotifyLeaderChangedwould delegate to the collaborator(the leader-change cleanup of
LEADER_MISSING/FAILEDstatuses + failure counters).ReconcilePlanTestreferenceArcadeStateMachine.classifyReconcile/executeReconcilePlan/applyReconcileOutcomedirectly; they would move to target the new class.GetClusterHandlerandClusterAlertscallgetAcquireStatus/getDatabasesWithAcquireState,so the accessors must remain reachable (likely via the reconciler instance held by the state machine).
Pure refactor - no behavior change.