|
| 1 | +# 02:最后 current 血缘证书 |
| 2 | + |
| 3 | +last-current carrier 的关键不是多记录一个版本号,而是证明一条不可拼接的因果链: |
| 4 | + |
| 5 | +```text |
| 6 | +某个节点确实是最后 X owner |
| 7 | + ↓ |
| 8 | +它在关闭写权限的同一次转换中冻结了这份 image |
| 9 | + ↓ |
| 10 | +image、source identity 和 authority transition 属于同一快照 |
| 11 | + ↓ |
| 12 | +此后没有新的 current owner、formation 或 authority generation 取代它 |
| 13 | +``` |
| 14 | + |
| 15 | +只有整条链成立,PI 才是“last-current carrier 候选”;它依然不是 X authority。 |
| 16 | + |
| 17 | +## 1. 证据强度阶梯 |
| 18 | + |
| 19 | +不同观测的证明力不能混用: |
| 20 | + |
| 21 | +```mermaid |
| 22 | +flowchart BT |
| 23 | + T[topology: node appears in PI set] |
| 24 | + W[watermark: observed progress boundary] |
| 25 | + P[provenance: who last advanced an observation] |
| 26 | + L[exact transition lineage] |
| 27 | + I[exact retained image identity] |
| 28 | + A[master revalidation + authority grant] |
| 29 | +
|
| 30 | + T --> W --> P --> L --> I --> A |
| 31 | +
|
| 32 | + T -. insufficient for grant .-> NO[no write authority] |
| 33 | + W -. insufficient for grant .-> NO |
| 34 | + P -. insufficient for grant .-> NO |
| 35 | +``` |
| 36 | + |
| 37 | +| 证据 | 可以证明 | 不能证明 | |
| 38 | +|---|---|---| |
| 39 | +| PI holder set | 哪些节点可能保存某个 PI | 哪个 PI 最新、内容是什么 | |
| 40 | +| watermark | 某个观察值未低于已知边界 | 该值对应哪份 image、谁仍拥有它 | |
| 41 | +| historical provenance | 某次观察由哪个 source 推进 | source 当前仍保留同一份字节 | |
| 42 | +| transition lineage | image 与某次 X→N+PI 转换同源 | 当前 master 尚未被新轮次替代 | |
| 43 | +| retained image identity | proof 指向同一冻结 image | 可以绕过 master 直接写 | |
| 44 | +| current master grant | authority 在当前轮次被唯一提交 | requester 已完成本地安装 | |
| 45 | + |
| 46 | +因此,topology、watermark 和历史 provenance 都只能做**辅助复核**;它们不能互相拼凑成 |
| 47 | +last-current authority。 |
| 48 | + |
| 49 | +## 2. 证书的语义内容 |
| 50 | + |
| 51 | +公开架构只规定语义,不冻结具体 C struct、字节偏移或消息布局。一个 last-current lineage |
| 52 | +certificate 至少要把以下事实绑定为一个不可分割对象: |
| 53 | + |
| 54 | +| 语义域 | 必须回答的问题 | |
| 55 | +|---|---| |
| 56 | +| resource identity | 这是哪个数据库块/逻辑资源? | |
| 57 | +| source identity | 哪个节点、哪次启动/连接上下文冻结了它? | |
| 58 | +| formation identity | 它属于哪一轮集群成员关系? | |
| 59 | +| master/authority lineage | 哪次 authority transition 把最后 X 关闭并产生 N+PI? | |
| 60 | +| local image generation | source 本地缓存对象在冻结前后是否为同一代? | |
| 61 | +| page version boundary | image 对应哪个页面版本、SCN/LSN 边界? | |
| 62 | +| content identity | proof 与 image 内容是否可用 checksum/摘要精确 join? | |
| 63 | +| transition identity | duplicate/retry 是否仍指向同一次 X→N+PI? | |
| 64 | + |
| 65 | +这里的 generation 都属于各自域。不得把 page SCN、ship boundary、BufferDesc generation、 |
| 66 | +master generation 等不同量塞入同一个字段后假定它们可比较。 |
| 67 | + |
| 68 | +```mermaid |
| 69 | +classDiagram |
| 70 | + class LastCurrentCertificate { |
| 71 | + +ResourceIdentity resource |
| 72 | + +SourceIdentity source |
| 73 | + +FormationIdentity formation |
| 74 | + +AuthorityLineage transition |
| 75 | + +LocalImageGeneration image_generation |
| 76 | + +PageVersionBoundary page_version |
| 77 | + +ContentIdentity content_digest |
| 78 | + } |
| 79 | +
|
| 80 | + class RetainedImage { |
| 81 | + +ResourceIdentity resource |
| 82 | + +LocalImageGeneration image_generation |
| 83 | + +PageVersionBoundary page_version |
| 84 | + +ContentIdentity content_digest |
| 85 | + +Bytes immutable_bytes |
| 86 | + } |
| 87 | +
|
| 88 | + LastCurrentCertificate "1" --> "1" RetainedImage : exact join |
| 89 | +``` |
| 90 | + |
| 91 | +## 3. 证书必须在转换点产生 |
| 92 | + |
| 93 | +如果系统在看到 `N+PI` 后才回头组合历史记录,会遇到经典的 time-of-check/time-of-use |
| 94 | +问题:source 可能已经转移过多次,buffer slot 可能被重用,watermark 也可能由另一条路径推进。 |
| 95 | + |
| 96 | +正确的线性化点是:最后 X owner 仍拥有关闭写权限所需的本地与全局上下文时,在同一转换 |
| 97 | +critical section 内冻结证书和 image identity,然后才发布 X→N+PI。 |
| 98 | + |
| 99 | +```mermaid |
| 100 | +sequenceDiagram |
| 101 | + participant H as Last X holder |
| 102 | + participant B as Local buffer authority |
| 103 | + participant M as Resource master state |
| 104 | + participant R as Retained-pair owner |
| 105 | +
|
| 106 | + H->>B: lock exact resource/image generation |
| 107 | + H->>M: validate current X lineage |
| 108 | + H->>R: freeze certificate + image identity |
| 109 | + R-->>H: retained pair armed |
| 110 | + H->>B: close ordinary writes |
| 111 | + H->>M: publish X -> N+PI transition |
| 112 | + H->>B: release local critical section |
| 113 | +``` |
| 114 | + |
| 115 | +顺序约束: |
| 116 | + |
| 117 | +1. arm 失败时,不能先丢失最后 X 或释放 image; |
| 118 | +2. certificate 与 image identity 必须在写关闭前后做同代复核; |
| 119 | +3. X→N+PI 发布后,任何修改都必须通过新的 authority acquisition; |
| 120 | +4. duplicate 只能重放同一 immutable pair,不能重新采样一份“看起来相同”的页面。 |
| 121 | + |
| 122 | +## 4. 如何证明它是“最后一次” |
| 123 | + |
| 124 | +“source 曾经是 X holder”不够。master 必须能证明这次 transition 在当前 resource lineage 上没有 |
| 125 | +后继 current owner: |
| 126 | + |
| 127 | +```mermaid |
| 128 | +stateDiagram-v2 |
| 129 | + [*] --> X_CURRENT |
| 130 | + X_CURRENT --> PAIR_ARMED: freeze exact certificate + image |
| 131 | + PAIR_ARMED --> N_PI: commit X -> N+PI |
| 132 | + N_PI --> SUPERSEDED: another current/X generation committed |
| 133 | + N_PI --> CANDIDATE: no successor current, exact lineage current |
| 134 | + CANDIDATE --> GRANTABLE: master full revalidation |
| 135 | +
|
| 136 | + SUPERSEDED --> [*]: old pair can only retire |
| 137 | + CANDIDATE --> [*]: drift/mismatch => fail closed |
| 138 | +``` |
| 139 | + |
| 140 | +需要同时成立: |
| 141 | + |
| 142 | +- transition 是该 resource 当前 authority lineage 的末端; |
| 143 | +- source identity、formation 和 master session 仍然匹配; |
| 144 | +- source 节点仍被当前成员关系承认; |
| 145 | +- 该 source 的 PI membership 仍存在; |
| 146 | +- 没有 X/S holder 或更晚的 transition 与之冲突; |
| 147 | +- retained image 的本地 generation 和内容 identity 未发生漂移。 |
| 148 | + |
| 149 | +任何一项无法证明,都不能退化成“选择 watermark 最大的 PI”。 |
| 150 | + |
| 151 | +## 5. ABA 与重用防护 |
| 152 | + |
| 153 | +相同 BufferTag、相同节点甚至相同页面 SCN 都可能在不同 acquisition 中再次出现。证书必须区分: |
| 154 | + |
| 155 | +```mermaid |
| 156 | +flowchart LR |
| 157 | + A1[resource R / source A / generation 10] --> N1[N+PI pair P1] |
| 158 | + N1 --> X2[new X owner / generation 11] |
| 159 | + X2 --> N2[resource R / source A / generation 12 / pair P2] |
| 160 | +
|
| 161 | + P1[P1 bytes] -. same tag, stale lineage .-> REJECT[reject] |
| 162 | + N2 --> ACCEPT[P2 current candidate] |
| 163 | +``` |
| 164 | + |
| 165 | +- tag 相同不代表 transition 相同; |
| 166 | +- source node 相同不代表 incarnation 相同; |
| 167 | +- page SCN 相同不代表 BufferDesc generation 相同; |
| 168 | +- retry request 相同不代表 master session 未变化; |
| 169 | +- checksum 相同只能证明内容相同,不能证明 authority 相同。 |
| 170 | + |
| 171 | +## 6. Lineage diagnostic gate |
| 172 | + |
| 173 | +在启用该 fast path 前,应先有确定性诊断证明当前 `N+PI` 问题确实来自“最后 X holder 已完成 |
| 174 | +X→N+PI,但 current-holder 生命周期没有留下可直接路由的 holder”。诊断应区分三类结果: |
| 175 | + |
| 176 | +| 诊断结果 | 行为 | |
| 177 | +|---|---| |
| 178 | +| exact immediate lineage | 允许进入 retained-pair 路径 | |
| 179 | +| lineage 被后继 current 取代 | 丢弃旧 pair,路由到新 holder | |
| 180 | +| lineage 缺失或无法判定 | fail closed;修复 holder lifecycle 或进入 recovery | |
| 181 | + |
| 182 | +这道 gate 防止把一个 current-holder 记账缺陷隐藏成“PI promotion”。如果根因是 holder 本应仍在, |
| 183 | +优先修复 holder 生命周期,而不是扩大 fast path。 |
0 commit comments