release: v0.6.0 — 完全移除 IndexedDB,自研 KVStore 事务存储引擎(多key原子写/快照日志恢复/CRC自愈)+ KVStoreEngine + 旧库迁移工具 + 10万级压力验证 + 崩溃注入e2e
CI / test (20.x) (push) Successful in 10m53s
CI / test (22.x) (push) Successful in 10m47s
CI / test (24.x) (push) Successful in 10m42s
CI / e2e (push) Successful in 10m27s
CI / test (18.x) (push) Successful in 11m1s

This commit is contained in:
thzxx
2026-08-10 13:56:04 +08:00
parent 2668bd47cf
commit 24b3ca1079
74 changed files with 8016 additions and 7688 deletions
+5 -46
View File
@@ -10,8 +10,10 @@
import { AriaEngine } from '../src/engine/aria/index';
import { createSchema } from '../src/table/schema';
import { LSM } from '../src/engine/aria/index/lsm';
import { OPFSEngine } from '../src/engine/opfs';
import 'fake-indexeddb/auto';
import { installOPFSMock } from './helpers/opfs-mock';
beforeEach(() => { installOPFSMock(new Map()); });
let idbCounter = 0;
function uniqueDB(): string {
@@ -56,7 +58,7 @@ describe('P0 — close 后无残留后台任务', () => {
it('close 后立即 reopen 不被旧后台任务污染', async () => {
const dbName = uniqueDB();
const engine = new AriaEngine({
storageBackend: 'indexeddb',
storageBackend: 'opfs',
bufferPoolPages: 4,
memtableSizeThreshold: 32 * 1024,
checkpointInterval: 100000,
@@ -162,47 +164,4 @@ describe('P1 — 提交顺序与 close 等待', () => {
await engine.close();
});
it('OPFS close 等待挂起写完成(文件完整)', async () => {
// mock OPFS(跨实例共享)
const files = new Map<string, string>();
const dirMock = {
getDirectoryHandle: async (_n: string, _o?: any) => dirMock as any,
getFileHandle: async (name: string, opts?: any) => {
if (opts?.create) {
return {
createWritable: async () => ({
write: async (d: string) => {
// 模拟慢 I/O
await new Promise((r) => setTimeout(r, 30));
files.set(name, d);
},
close: async () => {},
}),
};
}
if (!files.has(name)) throw new Error('Not found');
return { getFile: async () => ({ text: async () => files.get(name)!, arrayBuffer: async () => new ArrayBuffer(0) }) };
},
removeEntry: async (n: string) => { files.delete(n); },
};
(dirMock as any).entries = () => ({
[Symbol.asyncIterator]: async function* () {
for (const [k] of files) yield [k];
},
});
const nav = (globalThis as any).navigator || {};
nav.storage = { getDirectory: async () => dirMock };
(globalThis as any).navigator = nav;
const engine = new OPFSEngine();
await engine.open('opfs-close', 1);
await engine.createTable(createSchema('t', { id: { type: 'string', primaryKey: true } }));
// 写入不等待(写 I/O 30ms 挂起)
const p = engine.insert('t', [{ id: '1' }]);
// 立即 close:必须等待挂起写完成
await engine.close();
await p;
// 文件完整(修复前 close 不等写 → 可能读到旧/空文件)
expect(files.get('t.json')).toContain('"1"');
});
});