release: v0.2.1 生产加固 — WAL CRC/约束激活/Hybrid提交顺序/RESTRICT外键/浏览器兼容表/debug模式/onError回调
This commit is contained in:
+9
-1
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user