release: v0.4.2 — 生产就绪与崩溃自愈 + 问题清单修复 + 版本迭代
CI / test (18.x) (push) Successful in 10m7s
CI / test (20.x) (push) Successful in 10m6s
CI / test (22.x) (push) Successful in 10m2s
CI / test (24.x) (push) Successful in 10m0s

This commit is contained in:
thzxx
2026-08-09 19:15:37 +08:00
parent a1e4f5071c
commit 22b0b1fad4
34 changed files with 6626 additions and 565 deletions
+8 -8
View File
@@ -287,16 +287,15 @@ describe('[v0.3.1] WAL 批量组提交', () => {
await db.defineTable('users', { id: { type: 'string', primaryKey: true }, name: { type: 'string' } });
const engine = db.getEngine() as any;
let before = 0;
const origRead = engine.backend.read.bind(engine.backend);
// 统计 __wal_ 写入次数
// v0.4.2: WAL 记录与 count 改用 writeMany 单事务原子写入(记录仍合并为 1 次落盘)
const origWriteMany = engine.backend.writeMany.bind(engine.backend);
const origWrite = engine.backend.write.bind(engine.backend);
let walWrites = 0;
engine.backend.write = async (key: string, data: ArrayBuffer) => {
if (key.startsWith('__wal_') && !key.startsWith('__wal_count')) walWrites++;
return origWrite(key, data);
engine.backend.writeMany = async (entries: Record<string, ArrayBuffer>) => {
const keys = Object.keys(entries);
if (keys.some((k) => k.startsWith('__wal_') && !k.startsWith('__wal_count'))) walWrites++;
return origWriteMany(entries);
};
void before; void origRead;
await db.table('users').insertMany([
{ id: '1', name: 'A' },
@@ -305,7 +304,8 @@ describe('[v0.3.1] WAL 批量组提交', () => {
{ id: '4', name: 'D' },
]);
expect(walWrites).toBe(1); // 4 行 1 次 WAL 写入
expect(walWrites).toBe(1); // 4 行合并为 1 次 WAL 落盘
void origWrite;
const rows = await db.query('SELECT * FROM users') as Record<string, unknown>[];
expect(rows).toHaveLength(4);
await db.close();