Skip to content

HA: follower crash-loops every 3s on 'Failed updateLastAppliedTermIndex: newTI (t:3) < oldTI (t:4)' after pod recreation — CLOSED-member auto-restart loops forever, divergedFollowerRecovery never triggers #5291

Closed

Description

@ruispereira

Found while validating the post-#5268/#5271/#5275 fixes on a fresh 26.8.1-SNAPSHOT (digest 8ee87c28…, all 3 nodes same build) — the membership/rejoin fixes work (the leader reconnected to the recreated pod immediately, live appender telemetry), but the recreated follower is stuck in an infinite 3-second crash-restart loop on a term-inverted entry in its persisted Raft log, and the new CLOSED-member auto-restart from #5271 keeps faithfully restarting it into the same crash.

Sequence

3-node StatefulSet, fresh parallel bootstrap earlier this morning (some transient failures during it, then all Ready). Then a single kubectl delete pod of arcadedb-0 (graceful — clean shutdown, no unclean-close recovery on restart). The recreated pod resumes its persisted Raft storage and loops:

08:57:42.477 INFO  [ArcadeStateMachine] ArcadeStateMachine initialized (groupId=group-E6A6271798FD)
08:57:42.513 SEVER [StateMachineUpdater] ..._2434@group-...-StateMachineUpdater caught a Throwable.
java.lang.IllegalStateException: ..._2434: Failed updateLastAppliedTermIndex: newTI = (t:3, i:4946) < oldTI = (t:4, i:4945)

08:57:45.288 SEVER [RaftServer$Division] Failed appendEntries* (leader heartbeat #9338-t4, previous=(t:4, i:4948), leaderCommit=4948):
org.apache.ratis.protocol.exceptions.ServerNotReadyException: ... is not in [STARTING, RUNNING]: current state is CLOSED

08:57:45.522 INFO  [ArcadeStateMachine] ArcadeStateMachine initialized (groupId=group-E6A6271798FD)   <- #5271 auto-restart, ~3s cadence
08:57:45.558 SEVER [StateMachineUpdater] ... Failed updateLastAppliedTermIndex: newTI = (t:3, i:4946) < oldTI = (t:4, i:4945)
... (92 iterations and counting in the first ~8 minutes)

Observations

  1. The on-disk Raft state is self-inconsistent: applied index is (t:4, i:4945) but the log entry at i:4946 carries term 3 — term going backwards with increasing index. Presumably a conflicting suffix from a pre-term-4 leader that should have been truncated when the term-4 leader overwrote it, with the truncation (or the applied-index marker) not persisted consistently. The morning bootstrap went through several quick term changes; the pod delete that exposed this was graceful.
  2. The HA/k8s: stranded follower's Raft server left CLOSED after failed auto-join — restarting the leader then causes a permanent full-cluster outage (quorum impossible) #5271 fix works but has no backoff/classification: the health monitor detects the CLOSED member and restarts it every ~3s, forever. After N identical crashes it should stop treating it as transient.
  3. divergedFollowerRecovery does not catch it: the reformat-and-rejoin path (divergedFollowerMaxReformats=5) apparently only classifies WAL-version-gap errors as divergence. This IllegalStateException from Ratis's updateLastAppliedTermIndex is arguably the clearest possible divergence signal, and it's exactly the case where a reformat would help — but it just crash-loops instead.
  4. Status masking: the leader's telemetry for the looping follower reads replicaStatus: HEALTHY, replicationLag: 0 — appends land in the brief STARTING→RUNNING window each cycle, so every status surface says healthy while the node crashes 20×/minute and readiness stays 503.

Suggested fixes

Recovery

Single-node reformat (wipe the node's raftStorageDirectory + force-recreate the pod) — will report back whether the new auto-join retry path re-adds it cleanly on this build.

Activity

  1. ruispereira commented on Jul 15, 2026

    @ruispereira
    ContributorAuthor

    Major update — the corruption is in the group's replicated state, not the node's local storage. We did the single-node reformat exactly as planned (verified the wipe target against the process cmdline: raftStorageDirectory=/home/arcadedb/databases/.raft-storage, no stray directory elsewhere; force-delete so nothing was re-persisted; the recreated pod's raft-storage dir is brand new, mtime = this boot).

    The freshly-wiped node crashes with the exact same inversion — newTI = (t:3, i:4946) < oldTI = (t:4, i:4945) — 0.8s after RaftHAServer configured, before anything else, and then loops (121 crashes so far this boot).

    For a node with zero local history to reach oldTI=(t:4, i:4945) and then be handed (t:3, i:4946), both must come from the cluster: the (unlogged) Raft snapshot install carries lastApplied=(t:4, i:4945), and the leader's retained log then serves an entry at i:4946 with term 3. Since term must be non-decreasing with index in a single log, one of the two is mis-stamped — the obvious suspect is the snapshot's lastIncludedTerm being stamped with the current term (4) instead of the term of entry 4945 (which, given i:4946 is t:3, must also have been ≤3).

    Practical consequence: every fresh joiner is poisoned — any node that needs a snapshot-based catch-up from this group crashes in the same loop, so the reformat-and-rejoin escape hatch is dead for this cluster. We're recovering stage with a full parallel reformat (wipe all three + simultaneous force-delete), which rebuilds the group log from index 0.

    Environment note for repro: the group went through several rapid term changes during this morning's parallel cold bootstrap (terms 1→4 within seconds, leadership transferred to the freshest copy by BootstrapElection) — the poisoned region of the log presumably dates from that window.

  2. ruispereira commented on Jul 15, 2026

    @ruispereira
    ContributorAuthor

    Per-pod logs from the current state (pod-0 reformatted+recreated again ~09:02, still crash-looping 22 min later), plus a network sanity check. Three additional findings for the record.

    pod-0 (crash-looping joiner, IP 10.126.57.187) — same inversion, now at leader heartbeat #19122:

    09:25:55.356 SEVER [RaftServer$Division] Failed appendEntries* ...arcadedb-1..._2434 -> ...arcadedb-0..._2434#19122-t4,previous=(t:4, i:4948),leaderCommit=4948,HEARTBEAT
      ServerNotReadyException: ..._2434@group-E6A6271798FD is not in [STARTING, RUNNING]: current state is CLOSED
    09:25:55.749 SEVER [StateMachineUpdater] ... caught a Throwable.
      java.lang.IllegalStateException: Failed updateLastAppliedTermIndex: newTI = (t:3, i:4946) < oldTI = (t:4, i:4945)
    

    pod-1 (leader) — the channel-reset escalation ran its full course against the crash-looping node and then gave up permanently:

    09:04:05 WARNI [ClusterMonitor] Follower '...arcadedb-0...' unreachable for 60000ms; triggering a replication-channel reset (attempt 1/5) ...
    09:05:05 ... (attempt 2/5)   09:06:05 ... (attempt 3/5)   09:07:05 ... (attempt 4/5)   09:08:05 ... (attempt 5/5)
    09:09:05 SEVER [ClusterMonitor] Follower '...arcadedb-0...' still unreachable after 5 replication-channel resets over 360000ms; giving up automatic channel recovery - operator intervention (e.g. a leadership transfer) is required.
    

    Note "unreachable" is misleading here — the node is perfectly reachable. From inside the leader pod:

    PING vcc-superx-arcadedb-0.vcc-superx-arcadedb.contact-center.svc.cluster.local (10.126.57.187): 56 data bytes
    64 bytes from 10.126.57.187: seq=0 ttl=42 time=0.586 ms
    64 bytes from 10.126.57.187: seq=1 ttl=42 time=0.495 ms
    64 bytes from 10.126.57.187: seq=2 ttl=42 time=0.518 ms
    

    DNS resolves to the current IP and the network is fine at 0.5ms — the RPCs fail because the target member is CLOSED in its 3-second crash window. So the reset-and-give-up path burns its 5 attempts (and its "requires operator intervention" terminal state) on a node whose problem was never the channel. Suggest the monitor distinguish connect-level failure from ServerNotReadyException — resetting the channel can't help the latter, and the give-up leaves a permanent dead appender once the node does recover.

    pod-2 (healthy follower) — still rejecting the recreated node's new IP against a stale allowlist, minutes after the new pod's DNS record existed:

    08:53:43 WARNI [PeerAddressAllowlistFilter] Cannot resolve cluster peer host '...arcadedb-0...' (DNS gap during recreation — expected)
    09:03:06 WARNI [PeerAddressAllowlistFilter] Rejecting Raft gRPC connection from non-peer address: 10.126.57.187 (allowed=[::1, 10.126.37.165, 10.126.31.213, 10.126.34.96, ...])
    09:03:09 WARNI ... Rejecting ... 10.126.57.187 (allowed=[..., 10.126.37.165, ...])   <- 10.126.37.165 is the PREVIOUS pod-0 incarnation
    09:03:16 WARNI ... Rejecting ... 10.126.57.187 (allowed=[..., 10.126.37.165, ...])
    

    If the #5268 re-resolve-on-miss fix (ba8827afe) is supposed to be in this snapshot, it isn't taking effect — three rejections of the same unknown IP over 10 seconds with the correct DNS record in place. Could you confirm whether the current 26.8.1-SNAPSHOT docker tag (our pods run digest 8ee87c28…, pulled this morning) already contains the #5268/#5271/#5275/#5276/#5277 commits? If not, part of today's report is us validating a pre-fix build and the only new defect here is the term-inverted snapshot/log state (previous comment) plus the two behavioral notes above.

  3. added this to the 26.8.1 milestone on Jul 15, 2026
  4. self-assigned this
    on Jul 15, 2026
  5. added theissue type on Jul 15, 2026
  6. added a commit that references this issue on Jul 15, 2026
  7. lvca commented on Jul 15, 2026

    @lvca
    Member

    Thanks for the very detailed report and the follow-up analysis - your finding that the inverted state lives in the group's replicated log (not the node's local storage) was spot on and saved a lot of digging.

    There are really two things here:

    1. The crash-loop itself (fixed). The follower kept crashing on the term-inverted entry, and the CLOSED-member auto-restart faithfully restarted it into the exact same crash forever, because the restart succeeds (the server starts) and only the background updater dies a moment later - so the existing "give up after N restarts" safety never counted it.

    I've changed the health monitor to detect this: after a bounded number of restarts that don't stick, it escalates once to a storage reformat + rejoin (which fixes a purely local corruption), and if the node still crash-loops it stops restarting and logs a single clear SEVERE alert asking for operator intervention - instead of looping ~15x/min indefinitely. Merged to main, so it'll be in the next 26.8.1-SNAPSHOT.

    2. The inverted log region on the leader. As you found, because the bad state is replicated, a single-node reformat can't help - the leader re-serves it to every fresh joiner. The fix above turns that situation into a loud, quiet-once alert rather than an endless loop, but the recovery for a group whose log is already poisoned remains what you did: a coordinated full-cluster reformat. Reproducing the original corruption (rapid term changes during a parallel cold bootstrap) is hard without the affected storage; if you can capture a .raft-storage from a poisoned node before wiping it, that would help us chase the source.

    The other two notes (the "unreachable" channel-reset burning its budget on a CLOSED node, and the stale-allowlist rejections) are tracked separately - the allowlist one looks like your image digest predates the #5268 fix, so it's worth confirming the build first.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  8. lvca commented on Jul 15, 2026

    @lvca
    Member

    Still working on some other issues discovered with this bug hunting...

  9. added a commit that references this issue on Jul 15, 2026
  10. lvca commented on Jul 15, 2026

    @lvca
    Member

    Follow-up on the two behavioural notes from your second comment.

    Status masking (fixed). You were right that a crash-looping follower was reported HEALTHY / lag 0. The leader was deciding health purely from how far behind the follower's log was, and a node that had briefly caught up before it started flapping keeps that "caught up" mark even while it stops answering. The leader now also looks at whether the follower has actually answered a request recently: a follower that looks caught up but hasn't responded within the unreachable threshold is reported as STALLED, not HEALTHY, so the status API, metrics and Studio no longer hide it. Merged to main.

    The "unreachable" channel reset. I looked at this one closely and decided to leave it as is. The give-up is only a log line - it re-arms automatically the moment the follower answers again, and it doesn't touch Ratis's own replication channel, so it doesn't leave a dead appender once the node recovers. The leader can't reliably tell "network down" from "member is up but CLOSED" from the data it has here, and changing it risked breaking the real DNS-recovery case it was built for. The wasted reset attempts are harmless (they just rebuild one channel), so it's noisy logging rather than a functional problem - and with the status fix above, that node now shows as STALLED anyway.

    Allowlist rejections. These point to your image digest predating the #5268 fix rather than a new bug - worth confirming the build first, as noted earlier.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  11. added 2 commits that reference this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions