release: v0.2.1 生产加固 — WAL CRC/约束激活/Hybrid提交顺序/RESTRICT外键/浏览器兼容表/debug模式/onError回调
CI / test (20.x) (push) Successful in 9m58s
CI / test (18.x) (push) Successful in 10m0s
CI / test (22.x) (push) Successful in 10m0s
CI / test (24.x) (push) Successful in 9m56s

This commit is contained in:
thzxx
2026-07-27 20:47:30 +08:00
parent 620cd11521
commit e6efa39d48
18 changed files with 357 additions and 27 deletions
+9 -1
View File
@@ -10,6 +10,7 @@
import type { IStorageEngine } from '../engine/interface';
import type { QueryPlan, TableSchema, DiskEngine } from '../constants';
import { DatabaseError } from '../constants';
import { MemoryEngine } from '../engine/memory';
import { IndexedDBEngine } from '../engine/indexeddb';
import { OPFSEngine } from '../engine/opfs';
@@ -140,8 +141,15 @@ export class HybridEngine implements IStorageEngine {
}
async commitTransaction(): Promise<void> {
await this.memoryEngine.commitTransaction();
// 先写磁盘,保证持久化优先;磁盘失败则回滚内存
await this.diskEngine.commitTransaction();
try {
await this.memoryEngine.commitTransaction();
} catch {
// 内存提交失败时回滚磁盘
await this.diskEngine.rollbackTransaction();
throw new DatabaseError('Hybrid commit failed: memory engine error after disk commit', 'TX_COMMIT_ERROR');
}
}
async rollbackTransaction(): Promise<void> {