release: v0.5.1 — 存储后端生产级硬化(CRC-32/全库加密/WAL分片/页面化存储/多标签页锁/e2e)+ 深度审查修复(假实现接线/死代码清理)
This commit is contained in:
@@ -27,31 +27,20 @@ describe('AriaEngine — MVCC 事务 + Savepoint', () => {
|
||||
expect(id1).not.toBe(id2);
|
||||
});
|
||||
|
||||
it('commit 后事务标记为非活跃', () => {
|
||||
it('commit 后版本标记已提交', () => {
|
||||
const txnId = (engine as any).mvcc.beginTransaction();
|
||||
(engine as any).mvcc.writeVersion('users', '1', { name: 'Alice' }, txnId);
|
||||
(engine as any).mvcc.commitTransaction(txnId);
|
||||
expect((engine as any).mvcc.isActive(txnId)).toBe(false);
|
||||
const store = (engine as any).mvcc.versionStore;
|
||||
expect(store.get('users.1')[0].committed).toBe(true);
|
||||
});
|
||||
|
||||
it('rollback 后事务标记为非活跃', () => {
|
||||
it('rollback 移除本事务版本', () => {
|
||||
const txnId = (engine as any).mvcc.beginTransaction();
|
||||
(engine as any).mvcc.writeVersion('users', '1', { name: 'Alice' }, txnId);
|
||||
(engine as any).mvcc.rollbackTransaction(txnId);
|
||||
expect((engine as any).mvcc.isActive(txnId)).toBe(false);
|
||||
});
|
||||
|
||||
it('事务中写入版本可读', () => {
|
||||
const txnId = (engine as any).mvcc.beginTransaction();
|
||||
(engine as any).mvcc.writeVersion('users', '1', { name: 'Alice', balance: 100 }, txnId);
|
||||
const val = (engine as any).mvcc.readVersion('users', '1', txnId);
|
||||
expect(val).not.toBeNull();
|
||||
expect(val!.name).toBe('Alice');
|
||||
});
|
||||
|
||||
it('未提交版本对其他事务不可见', () => {
|
||||
const txn1 = (engine as any).mvcc.beginTransaction();
|
||||
(engine as any).mvcc.writeVersion('users', '1', { name: 'Alice' }, txn1);
|
||||
const txn2 = (engine as any).mvcc.beginTransaction();
|
||||
expect((engine as any).mvcc.readVersion('users', '1', txn2)).toBeNull();
|
||||
const store = (engine as any).mvcc.versionStore;
|
||||
expect(store.has('users.1')).toBe(false);
|
||||
});
|
||||
|
||||
it('引擎层事务 commit 后数据可见', async () => {
|
||||
@@ -69,16 +58,14 @@ describe('AriaEngine — MVCC 事务 + Savepoint', () => {
|
||||
expect(await engine.count('users')).toBe(1);
|
||||
});
|
||||
|
||||
it('GC 清理过旧版本', () => {
|
||||
it('GC 清理过旧版本(保留最新 N 个)', () => {
|
||||
for (let i = 0; i < 200; i++) {
|
||||
const txnId = (engine as any).mvcc.beginTransaction();
|
||||
(engine as any).mvcc.writeVersion('users', '1', { ver: i }, txnId);
|
||||
(engine as any).mvcc.commitTransaction(txnId);
|
||||
}
|
||||
(engine as any).mvcc.gc(50);
|
||||
const txnId = (engine as any).mvcc.beginTransaction();
|
||||
expect((engine as any).mvcc.readVersion('users', '1', txnId)).not.toBeNull();
|
||||
(engine as any).mvcc.commitTransaction(txnId);
|
||||
expect((engine as any).mvcc.versionStore.get('users.1').length).toBe(50);
|
||||
});
|
||||
|
||||
// ---- Savepoint ----
|
||||
|
||||
Reference in New Issue
Block a user