tests/fuzz: listIndexes on a namespace the prefix never created is expected

`crash-fuzz.js` aborted with "harness error: MongoServerError: ns not found"
whenever the surviving prefix contained no write that created the collection --
a kill during the first in-flight command on a fresh log. `listIndexes` on a
missing namespace is NamespaceNotFound, which is what real MongoDB answers too,
so the server was right and the harness treated a legitimate state as its own
failure. Worse, it aborted the run instead of verifying that state, which is
exactly the state worth verifying.

Reproduces with `--seed 1234 --rounds 60` and is why seeded runs were unusable;
`--heavy` happened to miss it. Confirmed against the previous commit before
changing anything, so it is the harness and not the engine.

Both seeds now pass 60 cycles.
This commit is contained in:
2026-08-04 00:41:03 +03:00
parent 319a515b89
commit a9f625f82a

View File

@@ -498,7 +498,16 @@ async function verify(client, base, r, cycleNo) {
const coll = db.collection('c'); const coll = db.collection('c');
const dbDocs = await coll.find({}, { sort: { _id: 1 } }).toArray(); const dbDocs = await coll.find({}, { sort: { _id: 1 } }).toArray();
const dbMap = new Map(dbDocs.map((d) => [d._id, d])); const dbMap = new Map(dbDocs.map((d) => [d._id, d]));
const dbIndexes = await coll.indexes(); // `listIndexes` on a namespace that does not exist is NamespaceNotFound, which
// is what real MongoDB answers too -- and it is the *expected* state whenever
// the surviving prefix contains no write that created the collection (a kill
// during the first in-flight command on a fresh log). Treating it as a harness
// error made any seed whose first cycle crashed at prefix 0 abort the run
// instead of verifying it, which is exactly the case worth verifying.
const dbIndexes = await coll.indexes().catch((e) => {
if (e.code === 26 || /ns not found|NamespaceNotFound/i.test(e.message)) return [];
throw e;
});
const indexExists = dbIndexes.some((i) => i.name === 'k_1'); const indexExists = dbIndexes.some((i) => i.name === 'k_1');
if (VERBOSE) { if (VERBOSE) {
console.log(` [verify] indexes=${JSON.stringify(dbIndexes.map((i) => i.name))} baseIdx=${base.indexCreated} idxPos=${r.idxPos}`); console.log(` [verify] indexes=${JSON.stringify(dbIndexes.map((i) => i.name))} baseIdx=${base.indexCreated} idxPos=${r.idxPos}`);