fix(ds03): 早段held断言按发布代次比较整份索引
build / build (push) Successful in 1m25s

首轮到达held时按chunk-target取文档失败:早段数据库阶段失败前索引仍是
发布写入的源码分块,before-image的chunk-target本就不该出现。改为整份
读回等于applied,并显式断言chunk-target未提前回来。
This commit is contained in:
姚章浩
2026-11-02 07:10:56 +08:00
parent f076c3af9c
commit a1472ff29f
@@ -1006,32 +1006,35 @@ UPDATE knowledge_bases SET embedding_model_id='r38-model',vector_store_id='r38-v
}
heldIndex := recoveryIndexReadback(t, fx)
save("13-index-held.json", heldIndex)
heldDoc, ok := heldIndex["chunk-target"]
if !ok {
t.Fatal("chunk-target missing at held boundary")
}
heldSource := heldDoc["_source"].(map[string]any)
heldContent, _ := heldSource["content"].(string)
if earlyBranch {
// database 阶段失败时索引还没被恢复:既不能有恢复 marker,也不能回到 before-image。
if strings.HasPrefix(heldContent, indexRestoreClaimPrefix) {
t.Fatalf("early held index must not carry a restore marker: %q", heldContent)
// database 阶段失败时索引还没被恢复:整份读回必须仍是发布写入后的那一代,
// before-image 的 chunk-target 不能提前出现。
if !reflect.DeepEqual(appliedIndex, heldIndex) {
t.Fatalf("early held index must be exactly the applied publish generation (applied=%d docs, held=%d docs)",
len(appliedIndex), len(heldIndex))
}
appliedSource := appliedIndex["chunk-target"]["_source"]
if !reflect.DeepEqual(appliedSource, heldSource) {
t.Fatal("early held index must still be the applied publish content")
if _, ok := heldIndex["chunk-target"]; ok {
t.Fatal("before-image chunk-target reappeared before the index stage ran")
}
} else if fullShape {
// 对象分支里索引已恢复,marker 不能还在:否则说明失败的其实是 ES 分支。
if strings.HasPrefix(heldContent, indexRestoreClaimPrefix) {
t.Fatalf("object branch left the ES restore marker in place: %q", heldContent)
} else {
heldDoc, ok := heldIndex["chunk-target"]
if !ok {
t.Fatal("chunk-target missing at held boundary")
}
oldSource := beforeIndex["chunk-target"]["_source"]
if !reflect.DeepEqual(oldSource, heldSource) {
t.Fatalf("object branch index was not restored to its before-image")
heldSource := heldDoc["_source"].(map[string]any)
heldContent, _ := heldSource["content"].(string)
if fullShape {
// 对象/PG wiki 分支里索引已恢复,marker 不能还在:否则说明失败的其实是 ES 分支。
if strings.HasPrefix(heldContent, indexRestoreClaimPrefix) {
t.Fatalf("restored index left the ES restore marker in place: %q", heldContent)
}
oldSource := beforeIndex["chunk-target"]["_source"]
if !reflect.DeepEqual(oldSource, heldSource) {
t.Fatalf("index was not restored to its before-image")
}
} else if !strings.HasPrefix(heldContent, indexRestoreClaimPrefix) {
t.Fatalf("held index must still carry the restore marker, got %q", heldContent)
}
} else if !strings.HasPrefix(heldContent, indexRestoreClaimPrefix) {
t.Fatalf("held index must still carry the restore marker, got %q", heldContent)
}
events, refused := proxy.snapshot()
save("14-wire-held.json", map[string]any{"events": events, "refused": refused})