Skip to content

Refactor: extract DatabaseReconciler collaborator from ArcadeStateMachine (follow-up to #4727) #4748

Description

@lvca

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions