Search before asking
Version
Summary
After a databend-meta cluster is upgraded through the V002→V004 transition, followers' state machines remain permanently diverged from the leader's despite identical Raft logs. Followers report roughly half the SnapshotKeyCount and LastSeq of the leader, with no automatic convergence over months of normal operation. The only known recovery is wiping a follower's raft-dir and forcing a fresh snapshot install via --join.
This is consistent with a non-deterministic state-machine migration during V002→V004 — each replica ran the migration independently and arrived at a different state from the same prior log.
Affected versions
databend-meta images in the v1.2.7xx–v1.2.8xx range (observed on v1.2.881 and v1.2.790-nightly)
DataVersion: V004, in clusters that were originally on V002
What's Wrong?
Evidence
A 3-replica cluster with healthy Raft replication but diverged state machines:
|
meta-0 (Leader) |
meta-1 |
meta-2 |
CurrentTerm |
5569 |
5569 |
5569 |
LastLogIndex |
9,282,381 |
9,282,381 |
9,282,383 |
LastApplied |
T5569-N0.9282381 |
T5569-N0.9282381 |
T5569-N0.9282383 |
SnapshotKeyCount |
370,804 |
185,123 |
185,123 |
LastSeq |
22,248,393 |
9,786,823 |
9,786,823 |
Both followers carry the same diverged numbers, suggesting a simultaneous event (the upgrade) rather than runtime drift.
Replication reports all voters caught up to T5569-N0.9282381 — replication is healthy. Purged is well below LastApplied, so log compaction hasn't yet forced the followers into an InstallSnapshot and the divergence has stayed latent.
Pattern across multiple clusters
The same divergence shape (followers at one identical SKC/LastSeq, leader at a higher one) is observed across multiple independently-upgraded clusters. Severity varies (sub-1% to ~50% SnapshotKeyCount divergence). Clusters that have had operator-driven raft-dir resets on followers show zero drift, durable for months. Clusters that haven't carry the divergence indefinitely.
Why this looks like a non-deterministic upgrade migration
- Raft logs identical at every observable level → not a replication bug.
- Divergence is stable over time despite ongoing writes → not runtime drift.
- Both followers carry identical diverged numbers → simultaneous event.
- Emerged around V004 transition; absent on freshly-bootstrapped V004 clusters.
Most parsimonious explanation: a V002→V004 migration step ran per-replica and was non-deterministic.
Operational concern
Raft elections pick a leader based on log term/index, not state-machine content. If a drifted follower wins an election (e.g., the canonical leader's pod is preempted or its node fails), the cluster now operates against the diverged state. If the original leader is then down long enough for log compaction on the new leader to advance past its position, Raft sends InstallSnapshot from the drifted leader to the recovering pod and the canonical state machine is silently overwritten — total loss of the divergent keys.
This makes the latent divergence a real data-loss risk in any environment where a leader pod can fail and recover slowly.
What would help
- Confirm or refute that V002→V004 migration is meant to be deterministic across replicas.
- A safe upgrade path for future state-version transitions that doesn't risk per-replica divergence.
- Built-in drift detection —
databend-metactl status already exposes the relevant metrics; a peer-comparison check (built-in or documented pattern) would surface this kind of bug in hours instead of months.
- Optional: a built-in
databend-metactl resync-from-leader (or similar) that wipes local state and triggers snapshot install in a controlled way, so operators don't have to delete raft-dir and restart manually. The wipe has to happen before databend-meta starts — wiping a running process's storage directory races against its background compaction.
Happy to share full databend-metactl status output or any other diagnostic data that would help.
How to Reproduce?
Reproduction (best-effort)
There is no deterministic reproduction available because the specific migration step that diverged is unknown. The conditions appear to be:
- Bootstrap a
databend-meta cluster on a pre-V004 version (e.g., V002).
- Accumulate non-trivial state (>100k keys, mixed writes/deletes/expirations/transactions).
- Upgrade to a V004-capable version via rolling restart.
- Compare
SnapshotKeyCount and LastSeq across replicas via databend-metactl status.
The bug may be sensitive to the specific pre-upgrade workload (operations that V002 and V004 represent differently in the state machine).
Are you willing to submit PR?
Search before asking
Version
Summary
After a
databend-metacluster is upgraded through the V002→V004 transition, followers' state machines remain permanently diverged from the leader's despite identical Raft logs. Followers report roughly half theSnapshotKeyCountandLastSeqof the leader, with no automatic convergence over months of normal operation. The only known recovery is wiping a follower'sraft-dirand forcing a fresh snapshot install via--join.This is consistent with a non-deterministic state-machine migration during V002→V004 — each replica ran the migration independently and arrived at a different state from the same prior log.
Affected versions
databend-metaimages in thev1.2.7xx–v1.2.8xxrange (observed onv1.2.881andv1.2.790-nightly)DataVersion: V004, in clusters that were originally on V002What's Wrong?
Evidence
A 3-replica cluster with healthy Raft replication but diverged state machines:
CurrentTermLastLogIndexLastAppliedSnapshotKeyCountLastSeqBoth followers carry the same diverged numbers, suggesting a simultaneous event (the upgrade) rather than runtime drift.
Replicationreports all voters caught up toT5569-N0.9282381— replication is healthy.Purgedis well belowLastApplied, so log compaction hasn't yet forced the followers into anInstallSnapshotand the divergence has stayed latent.Pattern across multiple clusters
The same divergence shape (followers at one identical SKC/LastSeq, leader at a higher one) is observed across multiple independently-upgraded clusters. Severity varies (sub-1% to ~50%
SnapshotKeyCountdivergence). Clusters that have had operator-drivenraft-dirresets on followers show zero drift, durable for months. Clusters that haven't carry the divergence indefinitely.Why this looks like a non-deterministic upgrade migration
Most parsimonious explanation: a V002→V004 migration step ran per-replica and was non-deterministic.
Operational concern
Raft elections pick a leader based on log term/index, not state-machine content. If a drifted follower wins an election (e.g., the canonical leader's pod is preempted or its node fails), the cluster now operates against the diverged state. If the original leader is then down long enough for log compaction on the new leader to advance past its position, Raft sends
InstallSnapshotfrom the drifted leader to the recovering pod and the canonical state machine is silently overwritten — total loss of the divergent keys.This makes the latent divergence a real data-loss risk in any environment where a leader pod can fail and recover slowly.
What would help
databend-metactl statusalready exposes the relevant metrics; a peer-comparison check (built-in or documented pattern) would surface this kind of bug in hours instead of months.databend-metactl resync-from-leader(or similar) that wipes local state and triggers snapshot install in a controlled way, so operators don't have to deleteraft-dirand restart manually. The wipe has to happen beforedatabend-metastarts — wiping a running process's storage directory races against its background compaction.Happy to share full
databend-metactl statusoutput or any other diagnostic data that would help.How to Reproduce?
Reproduction (best-effort)
There is no deterministic reproduction available because the specific migration step that diverged is unknown. The conditions appear to be:
databend-metacluster on a pre-V004 version (e.g., V002).SnapshotKeyCountandLastSeqacross replicas viadatabend-metactl status.The bug may be sensitive to the specific pre-upgrade workload (operations that V002 and V004 represent differently in the state machine).
Are you willing to submit PR?