summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-07-12 13:15:11 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-10 09:44:30 +0000
commite1802cd162d43c2cf3c647a7f3cdfb93c149eb90 (patch)
treeb6a8d79ead8ac4e501d4fdf8a64b45e240c90120
parent58fb882fea697627e40a8d5cca9a34785c3e9659 (diff)
downloadmongo-e1802cd162d43c2cf3c647a7f3cdfb93c149eb90.tar.gz
SERVER-58280 initial sync aborts index builds before applying collMod
This fixes initial sync issues during oplog application when indexes are being hidden/unhidden - these index operations are encoded as collMod commands. (cherry picked from commit 8922a0ea148c2d883ce724190e0d20a2e2bfd253)
-rw-r--r--jstests/noPassthrough/initial_sync_aborts_two_phase_index_builds_hide_index.js2
-rw-r--r--src/mongo/db/repl/oplog.cpp1
2 files changed, 3 insertions, 0 deletions
diff --git a/jstests/noPassthrough/initial_sync_aborts_two_phase_index_builds_hide_index.js b/jstests/noPassthrough/initial_sync_aborts_two_phase_index_builds_hide_index.js
index 000f72410a9..f1e2eae9caf 100644
--- a/jstests/noPassthrough/initial_sync_aborts_two_phase_index_builds_hide_index.js
+++ b/jstests/noPassthrough/initial_sync_aborts_two_phase_index_builds_hide_index.js
@@ -57,6 +57,8 @@ let secondary = rst.restart(1, {
checkLog.containsJson(secondary, 21138);
assert.commandWorked(coll.insert({a: 2}));
+assert.commandWorked(coll.hideIndex({a: 1}));
+assert.commandWorked(coll.unhideIndex({a: 1}));
assert.commandWorked(coll.dropIndex({a: 1}));
IndexBuildTest.pauseIndexBuilds(secondary);
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index c4db859b2d5..5b2ae9cfea5 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -170,6 +170,7 @@ void abortTwoPhaseIndexBuilds(OperationContext* opCtx,
opCtx, nss.db(), reason, true /* onlyAbortTwoPhaseIndexBuilds */);
} else if (commandType == OplogEntry::CommandType::kDrop ||
commandType == OplogEntry::CommandType::kDropIndexes ||
+ commandType == OplogEntry::CommandType::kCollMod ||
commandType == OplogEntry::CommandType::kRenameCollection) {
const boost::optional<UUID> collUUID =
CollectionCatalog::get(opCtx).lookupUUIDByNSS(opCtx, nss);