2023-11-16 21:26:24 +00:00
|
|
|
/**
|
|
|
|
|
* Tests dbCheck with old format index keys and verifies that no inconsistency is found.
|
|
|
|
|
*
|
|
|
|
|
* @tags: [
|
2025-01-28 09:48:58 -05:00
|
|
|
* requires_fcv_80
|
2023-11-16 21:26:24 +00:00
|
|
|
* ]
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
import {DbCheckOldFormatKeysTest, defaultNumDocs} from "jstests/replsets/libs/dbcheck_old_format_keys_test.js";
|
2024-03-26 10:59:00 +08:00
|
|
|
import {
|
|
|
|
|
assertCompleteCoverage,
|
2023-11-16 21:26:24 +00:00
|
|
|
checkHealthLog,
|
2024-03-26 10:59:00 +08:00
|
|
|
clearHealthLog,
|
2023-11-16 21:26:24 +00:00
|
|
|
forEachNonArbiterNode,
|
|
|
|
|
logQueries,
|
2025-08-21 10:17:44 -07:00
|
|
|
runDbCheck,
|
2023-11-16 21:26:24 +00:00
|
|
|
} from "jstests/replsets/libs/dbcheck_utils.js";
|
|
|
|
|
|
|
|
|
|
const dbName = "testDB";
|
|
|
|
|
const collName = "oldFormatIndexKeyTestColl";
|
|
|
|
|
|
|
|
|
|
const dbCheckTest = new DbCheckOldFormatKeysTest({});
|
|
|
|
|
dbCheckTest.insertOldFormatKeyStrings(dbName, collName);
|
|
|
|
|
|
|
|
|
|
const rst = dbCheckTest.getRst();
|
|
|
|
|
const primary = dbCheckTest.getPrimary();
|
2024-03-26 10:59:00 +08:00
|
|
|
clearHealthLog(rst);
|
2023-11-16 21:26:24 +00:00
|
|
|
|
2024-03-26 10:59:00 +08:00
|
|
|
jsTestLog("Running dbCheck dataConsistencyAndMissingIndexKeysCheck");
|
2025-08-21 10:17:44 -07:00
|
|
|
runDbCheck(
|
|
|
|
|
rst,
|
|
|
|
|
primary.getDB(dbName),
|
|
|
|
|
collName,
|
|
|
|
|
{validateMode: "dataConsistencyAndMissingIndexKeysCheck"},
|
|
|
|
|
true /*awaitCompletion*/,
|
|
|
|
|
);
|
2024-03-26 10:59:00 +08:00
|
|
|
|
|
|
|
|
// Verify that no error or warning health log entries were logged.
|
2025-08-21 10:17:44 -07:00
|
|
|
forEachNonArbiterNode(rst, function (node) {
|
2024-03-26 10:59:00 +08:00
|
|
|
checkHealthLog(node.getDB("local").system.healthlog, logQueries.allErrorsOrWarningsQuery, 0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
clearHealthLog(rst);
|
|
|
|
|
|
|
|
|
|
jsTestLog("Running dbCheck extraIndexKeysCheck");
|
2025-08-21 10:17:44 -07:00
|
|
|
runDbCheck(
|
|
|
|
|
rst,
|
|
|
|
|
primary.getDB(dbName),
|
|
|
|
|
collName,
|
|
|
|
|
{validateMode: "extraIndexKeysCheck", secondaryIndex: "a_1"},
|
|
|
|
|
true /*awaitCompletion*/,
|
|
|
|
|
);
|
2023-11-16 21:26:24 +00:00
|
|
|
|
|
|
|
|
// Verify that no error or warning health log entries were logged.
|
2025-08-21 10:17:44 -07:00
|
|
|
forEachNonArbiterNode(rst, function (node) {
|
2023-11-16 21:26:24 +00:00
|
|
|
checkHealthLog(node.getDB("local").system.healthlog, logQueries.allErrorsOrWarningsQuery, 0);
|
2025-08-21 10:17:44 -07:00
|
|
|
assertCompleteCoverage(
|
|
|
|
|
node.getDB("local").system.healthlog,
|
|
|
|
|
defaultNumDocs,
|
|
|
|
|
"a" /*indexName*/,
|
|
|
|
|
null /* docSuffix */,
|
|
|
|
|
null /* start */,
|
|
|
|
|
null /* end */,
|
|
|
|
|
);
|
2023-11-16 21:26:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dbCheckTest.stop();
|