From a4cffa9d6a2c902101f19b3b54af2714b0f4af4a Mon Sep 17 00:00:00 2001 From: Yu Jin Kang Park Date: Wed, 17 May 2023 12:31:11 +0000 Subject: SERVER-77214 Add buildUUID, db, and collectionUUID to index build data corruption log message --- .../noPassthrough/index_build_out_of_order_scan.js | 22 +++++++++++++++++++++- src/mongo/db/index_builds_coordinator.cpp | 7 ++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/jstests/noPassthrough/index_build_out_of_order_scan.js b/jstests/noPassthrough/index_build_out_of_order_scan.js index f6491f9c70e..ebc2d1dbf00 100644 --- a/jstests/noPassthrough/index_build_out_of_order_scan.js +++ b/jstests/noPassthrough/index_build_out_of_order_scan.js @@ -31,6 +31,11 @@ const hangAfterInitializingIndexBuild = const createIdx = IndexBuildTest.startIndexBuild( primary, primaryColl.getFullName(), {a: 1}, null, [ErrorCodes.DataCorruptionDetected]); +const buildUUID = + IndexBuildTest + .assertIndexesSoon(primaryColl, 2, ['_id_'], ['a_1'], {includeBuildUUIDs: true})['a_1'] + .buildUUID; + hangAfterInitializingIndexBuild.wait(); const WTRecordStoreUassertOutOfOrder = configureFailPoint(primary, "WTRecordStoreUassertOutOfOrder"); @@ -39,8 +44,23 @@ const hangBeforeAbort = hangAfterInitializingIndexBuild.off(); hangBeforeAbort.wait(); + +// Get collection UUID. +const collInfos = primaryDB.getCollectionInfos({name: primaryColl.getName()}); +assert.eq(collInfos.length, 1, collInfos); +const collUUID = collInfos[0].info.uuid; + // Index build: data corruption detected. -checkLog.containsJson(primary, 7333600); +checkLog.containsJson(primary, 7333600, { + buildUUID: function(uuid) { + return uuid && uuid["uuid"]["$uuid"] === extractUUIDFromObject(buildUUID); + }, + db: primaryDB.getName(), + collectionUUID: function(uuid) { + jsTestLog(collUUID); + return uuid && uuid["uuid"]["$uuid"] === extractUUIDFromObject(collUUID); + } +}); assert.eq(1, primaryDB.serverStatus().indexBuilds.failedDueToDataCorruption); // Disable out-of-order failpoint so clean-up can succeed. diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index 38b1da5703f..4961d533f68 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -2632,7 +2632,12 @@ void IndexBuildsCoordinator::_cleanUpAfterFailure(OperationContext* opCtx, if (status.code() == ErrorCodes::DataCorruptionDetected) { indexBuildsSSS.failedDueToDataCorruption.addAndFetch(1); - LOGV2(7333600, "Index build: data corruption detected", "status"_attr = status); + LOGV2(7333600, + "Index build: data corruption detected", + "buildUUID"_attr = replState->buildUUID, + logAttrs(replState->dbName), + "collectionUUID"_attr = replState->collectionUUID, + "error"_attr = status); } if (IndexBuildProtocol::kSinglePhase == replState->protocol) { -- cgit v1.2.1