Repository navigation
Description
Description
A three-voter LogService/HAKeeper cluster can fail to restart as a whole when more than one node's persisted mo-logservice.metadata retains both a removed HAKeeper replica ID and its current replacement ID for shard 0. With all peers down during startup, the zombie self-check has no authoritative membership reply. startReplicas then tries to start both IDs for the same shard in one NodeHost; NewService returns shard already exist and mo-service panics. If two of three nodes have this metadata, the remaining node cannot form quorum, so ordinary process restarts do not recover the cluster.
Environment and preconditions
- Isolated three-voter cluster on
10.222.1.51, test binary from thed61a7206LogService chaos bundle; concrete HAKeeperservice-addressesare configured. No TN/CN was running. - Immediately before shutdown, data shard 1 voters: node1
385027, node2395266, node3477185; HAKeeper shard 0 voters: node1385028, node2395265, node3477186. - node1's persisted metadata also contains removed shard-0 IDs
131073and374786; node2's contains removed shard-0 ID131074. The old Raft files remain on disk. These records arose during earlier long-outage/replacement cycles; the complete original metadata files are preserved asmo-logservice.metadata.before-cold-recoveryin the isolated test directory. - All three stores are stopped together before starting any of them. The test waits for data-directory locks to release. With healthy peers online, the membership self-check can filter the old IDs, so this cold-start precondition matters.
Stable reproduction
On the prepared isolated directory:
root=/home/mo/jxm/logservice-chaos-20261103-d61a7206
python3 "$root/reproduce_cold_restart.py" "$root" --rounds 3The script requires all three test nodes initially running. Each round:
- Save the verified readback and current clean metadata; stop node1, node2 and node3, and wait for the directory locks to release.
- Restore the original metadata backup on node1/node2, preserving each store UUID, Raft directory, and original
bootstrap-cluster=trueconfiguration. - Start all three nodes with their original configurations; inspect process status and new startup logs.
- For test-cluster recovery only, stop the surviving node3, restore the known-current-ID metadata and start all three nodes using temporary
bootstrap-cluster=falseconfigs for node1/node2. Check membership and readback before the next round.
Result: 3/3 rounds: node1 and node2 each log panic: shard already exist and exit; node3 remains running with one vote. The three subsequent test recoveries each restored the same 351-record readback from LSN 9451 (SHA256 bb28f629f8e5fa5378904365d1c64fab8f1cc3e806df9b06b4db64e2a733c5ac). The test cluster is running with three voters after the final recovery. An earlier harness attempt started before Dragonboat locks were released and produced failed to lock data directory; that invalid attempt is excluded from 3/3.
Representative startup logs on both failing nodes:
zombie self-check: getShardMembership failed ... connect: connection refused
[00000:31073] replaying raft logs # node1 old HAKeeper ID
addMetadata for shardID 0, replicaID 131073 skipped, dupl shard
panic: shard already exist
main.startLogService ... cmd/mo-service/main.go:549
Setting bootstrap-cluster=false without removing the duplicate local metadata still produced the same panic. Therefore the failing path is NewService/startReplicas, before later bootstrap logic. After filtering old IDs in the isolated test only, Dragonboat recovered data shard replicas from their imported snapshots (indices 7826, 7825, 8464), all three addresses returned the same retained WAL data, and subsequent writes succeeded. No data corruption was observed.
Expected behavior
A legitimate whole-cluster cold restart must use the current persisted Raft membership, avoid starting two local replicas of the same shard, and restore a quorum without manually editing metadata. If the current membership cannot be established during startup, the store must not panic or silently select an obsolete voter. A first-time cluster bootstrap must still work.
Code path and scope
pkg/logservice/store.go:365checkZombieReplicasis best-effort: when no peer answers authoritatively, it returns no zombies. That policy allows cold bootstrap but does not resolve multiple persisted IDs for one shard.pkg/logservice/store.go:485startReplicasiterates every unfiltered local metadata record and callsNodeHost.StartReplicafor each. It does not reconcile duplicate shard IDs before the second start.cmd/mo-service/main.go:549panics onNewServiceerror.
This differs from #27803 (discovery-only warm restart with no concrete addresses) and #32135 (old initial ID absent from local metadata but reintroduced by bootstrap config). Here concrete peer addresses exist, old IDs remain in local metadata, and all peers are temporarily unavailable during cold start.
Impact and evidence
Two out of three stores can repeatedly fail at startup, preventing both the data and HAKeeper shards from forming a majority. The observed effect is cluster unavailability; no confirmed WAL loss or corruption.
Raw evidence on 51: $root/cold-repeat-verified2-20261104.log, node-{1,2}/stdout.log, the two mo-logservice.metadata.before-cold-recovery files, and restart-20261104.* readback files. The script is $root/reproduce_cold_restart.py. Manual metadata filtering was performed only to recover the isolated test cluster and is not a proposed production fix.
A regression should cover multiple historical IDs for one shard on at least two stores, all-peers-down startup with concrete service addresses, genuine first bootstrap, and normal single-node restart while peers are available.
Activity
jiangxinmeng1 commentedon Nov 4, 2026
Additional cold-start boundary tests on the same isolated three-voter cluster:
bootstrap-cluster=trueconfigs. Both shards returned the same three-member views; retained WAL readback matched the pre-stop SHA256, and three new appends succeeded. This controls for bootstrap configuration by itself.panic: shard already exist. Clean node2/node3 then formed a working 2/3 majority and completed three appends/readbacks. Restarting node1 again with the same stale metadata after those peers were online succeeded: startup skipped IDs131073and374786, and the three-member views returned.shard not foundfor the data-shard lookup; node1 and node2 both panicked when started. After restoring only the known-current metadata in this test environment, all three voters recovered and retained readback matched the pre-stop SHA256.The practical boundary is whether startup can obtain a usable peer membership view before it processes multiple local IDs for one shard. One healthy store online is insufficient in this tested topology; two healthy stores allowed the stale third store to rejoin. Full evidence and hashes: three-node failure report. The reproduction script is here.
fix(logservice): harden reads, proposals, snapshots, truncation, and …
XuPeng-SH commentedon Nov 6, 2026
QA 交接:#32149 已于 2026-11-06 07:40:26 UTC 合入 main,merge
ee5e93bcefd4f04bcda6b8e5002eef96038396d3,最终 headf83150eb8ffb17a3d91a3fbf6865e5a0d0b9ec2e。转交 @Ariznawlll 验证,不代表验收通过。修复范围:普通 HAKeeper 冷启动在本地保留多个历史 replica ID、peer membership 无法回答时,选择未被判为 zombie 的最高本地 HAKeeper ID,跳过旧 ID,避免同一 NodeHost 为 shard 0 启动两个副本;已有 replacement 运行时 bootstrap 不重放配置中的初始 ID。这依赖 HAKeeper replica ID 单调分配,不是任意损坏 metadata 的恢复承诺。
已完整核对正文及 1 条评论、PR 最终 diff 和讨论。旧构建中的 3/3 全集群冷启动 panic、一个健康节点不足而两个健康节点可救回的边界,均属于修复前证据,暂无本次合并版本的已验证反例。作者报告真实三 voter 历史 metadata 冷重启回归及组合分支包测试通过;最新本地验证和 approved review 绑定旧 head
790bca9921,Mergify 报告合并门禁CI Required成功。本轮未执行本地/集群测试,也未修改测试或生产 metadata。QA 建议:至少两个节点保留旧/新 shard-0 ID,原配置下全部停机、等待目录锁释放后冷启,确认无 duplicate-shard panic、恢复两 shard quorum、原有 WAL hash/LSN/payload 一致且新写成功;另做单节点 stale、单个 clean 节点先起、两 healthy peer 可回答、干净首次 bootstrap、初始 ID 已不存在的 replacement 对照。最终回归用 membership probe 注入“无人应答”,不是已完成三 voter 网络 chaos 或任意灾难恢复验证。#27803 的 discovery-only 路径及其他 LogService 故障应按各自范围验收。
Ariznawlll commentedon Nov 22, 2026
阶段性测试结果
在官方 main
cc2c82dc4a6cb2cbcc046ef9caebde50c6004b15上,TestHAKeeperColdRestartWithHistoricalReplicas及成员存在/缺失、RPC 失败、无地址、节点意见不一致和 zombie 跳过等定向用例以go test -race -count=3通过。冷启动用例在同一测试进程内创建真实的三个 LogService 服务:两节点构造多个历史 HAKeeper 副本记录,全部关闭后重新启动,验证选择当前副本并重新选出 leader;第三节点的 replacement bootstrap 也保持正确。成员查询“无人应答”由测试注入,不能等同于真实网络隔离。
本次未验证多机/多进程全集群故障、TN/TAE WAL hash 与 payload、业务新写入或其他生产恢复边界;因此 Issue 暂保持开放。
Ariznawlll commentedon Nov 24, 2026
结论
验收通过,关闭本 Issue。此前阶段性验证缺少的真实磁盘持久化、原 WAL 数据保留及恢复后新写入已经补齐;两个节点同时保留多个历史 HAKeeper replica ID、全部 peer 不可用时,三 voter 能选择当前副本并恢复 leader,不再触发
shard already exist启动失败。测试版本与修复范围
main@cc2c82dc4a6cb2cbcc046ef9caebde50c6004b15。main@d9a43b3156dd6ee54f14bdd4197071e522efd285;MOTR workflow head 为5cdb11b98b19ca90630049e07f7831db769338ba。ee5e93bcefd4f04bcda6b8e5002eef96038396d3。Verify issue 32151 historical replica cold restart和Verify issue 32151 disk-backed cold restart均成功。原冷启动场景
TestHAKeeperColdRestartWithHistoricalReplicas以-count=3执行,3/3 通过:go test -race -count=3通过。真实磁盘、WAL 与新写验证
MOTR 注入的 disk-backed 控制使用
vfs.Default和每个测试独立的临时磁盘目录,两个测试各执行 3 次,合计 6/6 通过:TestQA32151DiskColdRestart:重复上述双节点多历史 ID、全停后无人应答的冷启动,验证当前 replica 和 leader 恢复。TestQA32151DiskColdRestartRetainsWAL:另外建立真实三 voter data shard,在停止前提交qa-wal-before;冷启动后按原 LSN 读回,断言完整 record bytes 与提交前完全一致,再成功 Appendqa-wal-after,且新 LSN 大于原 LSN。回归去向与边界
pkg/logservice/zombie_repro_test.go;磁盘与 WAL 控制位于 MOTR.github/qa/issue_32151_disk_test.go,由.github/workflows/qa-main-issue-regression.yml强制检查每个测试的 3 次 PASS 计数。