GitNexus/gitnexus/test/helpers/publication-live-wal.mjs
Gergő Magyar c8629f1b6c
fix(storage): preserve published graph on rebuild failure (#3613)
* fix(storage): preserve published graph on rebuild failure (U1)

* test(storage): strengthen publication review coverage (U1)

* test(storage): align publication evidence (U1)

* fix(storage): retain completed recovery archives

* fix(storage): preserve quarantines before cache reads

* ci: run staged publication benchmark guard

* fix(ci): declare WAL replay probe determinism

Document that the bounded recovery read drains and discards its rows. Only WAL replay success is observed; row identity and query behavior are unchanged. The existing 21 query-determinism checks pass.

* test(storage): cover publication across platforms

* test(ci): exclude POSIX suite from Windows estimates

* test: allow native publication retry to finish

* test: verify Windows incremental recovery

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
2026-10-17 18:45:11 +01:00

34 lines
1.1 KiB
JavaScript

import fs from 'node:fs/promises';
import lbug from '@ladybugdb/core';
const [dbPath, mode] = process.argv.slice(2);
const db = new lbug.Database(dbPath, 256 * 1024 * 1024, false, false, 1024 ** 3);
const conn = new lbug.Connection(db);
async function query(cypher) {
const result = await conn.query(cypher);
for (const cursor of Array.isArray(result) ? result : [result]) {
try {
await cursor.getAll();
} finally {
await cursor.close();
}
}
}
await query('CHECKPOINT');
await query(
"CREATE (:Function {id: 'Function:wal.ts:walOnly', name: 'walOnly', filePath: 'wal.ts', startLine: 1, endLine: 1})",
);
const main = await fs.readFile(dbPath);
const wal = await fs.readFile(`${dbPath}.wal`);
await conn.close();
await db.close();
// Restore real committed WAL bytes to simulate interruption before consolidation.
await fs.writeFile(dbPath, main);
if (mode === 'checkpoint') {
await fs.writeFile(`${dbPath}.wal.checkpoint`, wal);
for (const suffix of ['.wal', '.shadow', '.checkpoint.intent.lock', '.checkpoint.apply.lock']) {
await fs.writeFile(`${dbPath}${suffix}`, '');
}
} else {
await fs.writeFile(`${dbPath}.wal`, wal);
}