Files
mongo/jstests/disk/log_metadata.js
DennisSHCheung 6846ec39db SERVER-115043 Log the contents of the WiredTiger metadata before aborting when it is inconsistent (#47622)
GitOrigin-RevId: ecfbd51f4913dd292a60a2d96db60599c7c5d5ef
2026-02-08 23:06:24 +00:00

44 lines
1.6 KiB
JavaScript

/**
* Tests that when WT metadata table is logged when checkApplicationMetadataFormatVersion fails.
*
* The `requires_persistence` is necessary because we need an actual disk to write data.
* @tags: [
* requires_persistence,
* requires_wiredtiger,
* ]
*/
import {getUriForIndex, runWiredTigerTool, startMongodOnExistingPath} from "jstests/disk/libs/wt_file_helper.js";
// Because this test intentionally crashes the server, we instruct the
// the shell to clean up after us and remove the core dump.
TestData.cleanUpCoreDumpsFromExpectedCrash = true;
const baseName = jsTestName();
const dbpath = MongoRunner.dataPath + baseName + "/";
resetDbpath(dbpath);
let conn = MongoRunner.runMongod({dbpath: dbpath});
let db = conn.getDB("test");
assert.commandWorked(db.createCollection(baseName));
let coll = db.getCollection(baseName);
assert.commandWorked(coll.createIndex({a: 1}, {unique: true}));
let uri = getUriForIndex(coll, "a_1");
// Invalidate WT metadata table.
jsTestLog(`Modifying table: ${uri}`);
MongoRunner.stopMongod(conn, null, {skipValidation: true});
runWiredTigerTool("-h", conn.dbpath, "alter", "table:" + uri, "app_metadata=(abc=123)");
assert.throws(() => {
conn = startMongodOnExistingPath(dbpath);
});
assert.soon(() => {
const foundId = rawMongoProgramOutput(".*").match(/\"id\":11504300/);
const expectedOutput = `${uri}","value":"app_metadata=(abc=123),`;
const foundExpectedOutput = rawMongoProgramOutput(".*").includes(expectedOutput);
return foundId && foundExpectedOutput;
}, "Mongod log contained the full contents of the WT metadata table");