From a1472ff29fad05013819640b53bca42c214b455f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Mon, 2 Nov 2026 07:10:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(ds03):=20=E6=97=A9=E6=AE=B5held=E6=96=AD?= =?UTF-8?q?=E8=A8=80=E6=8C=89=E5=8F=91=E5=B8=83=E4=BB=A3=E6=AC=A1=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E6=95=B4=E4=BB=BD=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首轮到达held时按chunk-target取文档失败:早段数据库阶段失败前索引仍是 发布写入的源码分块,before-image的chunk-target本就不该出现。改为整份 读回等于applied,并显式断言chunk-target未提前回来。 --- .../formal_maintenance_recovery_r38_test.go | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/internal/releaseadapter/v071/formal_maintenance_recovery_r38_test.go b/internal/releaseadapter/v071/formal_maintenance_recovery_r38_test.go index 3075b9d..8ff1d6a 100644 --- a/internal/releaseadapter/v071/formal_maintenance_recovery_r38_test.go +++ b/internal/releaseadapter/v071/formal_maintenance_recovery_r38_test.go @@ -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})