mpackdb
All repositories: gitoria
1.4 KB
// Stage a store with an OLD mpackdb lib (path in argv[2]); scenario argv[4]; dir argv[3].// compact-bug : insert, update, delete, close, reopen (startup compaction) + close => old lib writes wrong pk index// hardkill : insert+close, reopen, insert/update/delete, then SIGKILL itself (no close)import { rm } from 'node:fs/promises';import { resolve } from 'node:path';const { MPackDB } = await import(resolve(process.argv[2]));const dir = resolve(process.argv[3]);const scenario = process.argv[4];const opts = { primaryKey: 'sessionId', indexes: ['userId'], indexPersistInterval: 0 };await rm(dir, { recursive: true, force: true });let db = new MPackDB(`${dir}/sessions`, opts);for (let i = 0; i < 7; i++) await db.insert({ sessionId: 's' + i, userId: 'u' + (i % 3), n: i, pad: 'x'.repeat(10 + i * 7) });if (scenario === 'compact-bug') {await db.update('s1', r => ({ ...r, n: 100 }));await db.update('s4', r => ({ ...r, n: 400, extra: 'longer value'.repeat(5) }));await db.delete('s2');}await db.close();db = new MPackDB(`${dir}/sessions`, opts);if (scenario === 'compact-bug') { await db.find('s0').toArray().catch(() => {}); await db.close(); process.exit(0); }await db.insert({ sessionId: 's7', userId: 'u1', n: 7 });await db.update('s3', r => ({ ...r, n: 300 }));await db.delete('s5');await db.insert({ sessionId: 's8', userId: 'u2', n: 8 });await new Promise(r => setTimeout(r, 50));process.kill(process.pid, 'SIGKILL');
Branches
- mastermain branch
Latest commits
- cde6b2751.0.8: validate indexes against the data file on open, atomic index writes, invalidate index state before compaction; tests for pk find after compaction and hard killmre
- 87888725release 1.0.7caramboleyo
- c4cdb9b6node: import prefixes (Deno compat) + pre-existing index-state WIPcaramboleyo
- 0afb8f4bupdate now must be a callbackcaramboleyo
- cde73eb4release 1.0.6caramboleyo
- d01dda02add index hints, intersection, boundingBox; remove findByIndexcaramboleyo
- b8ffc1a0release 1.0.5caramboleyo
- d47876a1reimplemented lost features like indexed find and more testscaramboleyo
- 7f08da9afixed insert ignoring model definitioncaramboleyo
- 705774a9added flush before findcaramboleyo
- b4db6391initial commitcaramboleyo