summaryrefslogtreecommitdiff
path: root/jstests/disk
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2018-11-02 12:13:32 -0400
committerLouis Williams <louis.williams@mongodb.com>2018-11-05 10:51:59 -0500
commitc7553b861796c1581c85b3cbc4e55dcc9666aa0f (patch)
treef11b8f91fcc30c90b215a7f42e894aa523c5330c /jstests/disk
parent7dbcd710077bc4141e71730be9e12558880375e6 (diff)
downloadmongo-c7553b861796c1581c85b3cbc4e55dcc9666aa0f.tar.gz
SERVER-37796 Always salvage WiredTiger metadata regardless of error code when starting with repair
Diffstat (limited to 'jstests/disk')
-rw-r--r--jstests/disk/wt_repair_corrupt_metadata.js30
1 files changed, 29 insertions, 1 deletions
diff --git a/jstests/disk/wt_repair_corrupt_metadata.js b/jstests/disk/wt_repair_corrupt_metadata.js
index 16c12ac9bd7..0b5ecf8f3dd 100644
--- a/jstests/disk/wt_repair_corrupt_metadata.js
+++ b/jstests/disk/wt_repair_corrupt_metadata.js
@@ -65,13 +65,41 @@
mongod = startMongodOnExistingPath(dbpath, mongodOptions);
testColl = mongod.getDB(baseName)[collName];
- // The collection exists depite using an older turtle file because salvage is able to find
+ // The collection exists despite using an older turtle file because salvage is able to find
// the table in the WiredTiger.wt file.
assert(testColl.exists());
// We can assert that the data exists because the salvage only took place on the metadata,
// not the data.
assert.eq(testColl.find({}).itcount(), 1);
MongoRunner.stopMongod(mongod);
+
+ // Corrupt the .turtle file in a very specific way such that the log sequence numbers are
+ // invalid.
+ if (mongodOptions.hasOwnProperty('journal')) {
+ jsTestLog("Corrupting log file metadata");
+
+ let data = cat(turtleFile);
+ let re = /checkpoint_lsn=\(([0-9,]+)\)/g;
+ let newData = data.replace(re, "checkpoint_lsn=(1,2)");
+
+ print('writing data to new turtle file: \n' + newData);
+ removeFile(turtleFile);
+ writeFile(turtleFile, newData);
+
+ assertRepairSucceeds(dbpath, mongod.port, mongodOptions);
+
+ mongod = startMongodOnExistingPath(dbpath, mongodOptions);
+ testColl = mongod.getDB(baseName)[collName];
+
+ // The collection exists despite using a salvaged turtle file because salvage is able to
+ // find the table in the WiredTiger.wt file.
+ assert(testColl.exists());
+
+ // We can assert that the data exists because the salvage only took place on the
+ // metadata, not the data.
+ assert.eq(testColl.find({}).itcount(), 1);
+ MongoRunner.stopMongod(mongod);
+ }
};
// Repair may behave differently with journaling enabled or disabled, but the end result should