fix(P2): v0.6.3 原子性/一致性/资源治理 — 8 项修复 + 12 回归
CI / test (18.x) (push) Successful in 19m13s
CI / test (20.x) (push) Successful in 18m8s
CI / test (22.x) (push) Successful in 17m18s
CI / test (24.x) (push) Successful in 22m57s
CI / e2e (push) Successful in 9m53s

- KVStore 混合写单记录原子:新增 writeBatch(put+delete 同一条日志记录),
  KVStoreEngine 全部混合写路径统一(兑现真原子宣称,崩溃无新旧行并存)
- WAL full 模式写入失败抛错(此前 console.warn 吞错 → 崩溃即丢且无感知)
- MemoryEngine SET NULL 级联索引残留:复用 removeIndexEntries(消除虚假 UNIQUE_VIOLATION)
- delete 级联两阶段:先全量 RESTRICT 预检(沿 CASCADE 链递归)再执行,无部分级联
  (Memory/Aria 对齐)
- BufferPool 驱逐同步清理 pages Map(EvictionManager onRemove 回调,内存预算真实生效)
- MVCC commit 清理已提交版本(版本链仅作事务内 undo,消除行数据双份常驻)
- LSM.flush 重复入链修复(入链即置空 immutable)+ frozenMemtables 可见性时序
- rollbackToSavepoint 重建受影响表二级索引(消除过期索引条目)

测试 1114 → 1126(71 套件);行覆盖率 89.7%;版本 0.6.3
This commit is contained in:
thzxx
2026-08-13 10:30:39 +08:00
parent ef1934a38c
commit f97c5a6001
26 changed files with 1075 additions and 250 deletions
+13
View File
@@ -223,6 +223,19 @@ export class KVStore {
});
}
/**
* v0.6.3: 多 key 混合原子写(put + delete 编码进同一条日志记录)。
* 此前 KVStoreEngine 的 delete/update 主键变更等路径 putMany 与 deleteMany
* 分两次调用 = 两条记录:崩溃在两条记录之间 → 新旧行并存(重复行/脏数据),
* 与"一条日志记录 = 真原子"宣称不符。此方法保证混合操作全有或全无。
*/
async writeBatch(puts: Record<string, ArrayBuffer>, deletes: string[]): Promise<void> {
if (Object.keys(puts).length === 0 && deletes.length === 0) return;
await this.enqueue(async () => {
await this.appendRecord(puts, deletes);
});
}
/**
* v0.6.1: 追加写入(value 拼接语义)— aria WAL 分片等追加型数据用。
* 日志记录 APPEND 类型(O(chunk) 高效),恢复时按 seq 顺序拼接,