diff options
author | Benety Goh <benety@mongodb.com> | 2023-02-10 20:31:30 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-14 22:06:33 +0000 |
commit | 8b06b20e74a8ae34f4e41add8f152b9d1bcbbffc (patch) | |
tree | 918a2d8d5d562570b93d733f24e62615fdc35551 | |
parent | f8768543817db200e98be399dd2520e190ba3955 (diff) | |
download | mongo-8b06b20e74a8ae34f4e41add8f152b9d1bcbbffc.tar.gz |
SERVER-73858 Oplog batch application index builds on an empty collection should ignore same errors as non-empty collection case
(cherry picked from commit 0b0048e3ecb2a05eb68e6e36327ba50024bf7d9d)
-rw-r--r-- | jstests/replsets/initial_sync_geo_index_conflict.js | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 23 |
2 files changed, 14 insertions, 21 deletions
diff --git a/jstests/replsets/initial_sync_geo_index_conflict.js b/jstests/replsets/initial_sync_geo_index_conflict.js index 152fe6df2e4..400b681cef0 100644 --- a/jstests/replsets/initial_sync_geo_index_conflict.js +++ b/jstests/replsets/initial_sync_geo_index_conflict.js @@ -62,18 +62,6 @@ function runTest(numDocs) { failPoint.off(); } - // Initial sync fails due to unhandled IndexOptionsConflict error on empty collection. - if (numDocs == 0) { - assert.soon(function() { - return rawMongoProgramOutput().search( - /Fatal assertion.*40088.*IndexOptionsConflict.*name.*a_2d/) >= 0; - }); - - rst.stop(secondary, /*signal=*/undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT}); - rst.stopSet(); - return; - } - // Wait for initial sync to finish. rst.awaitSecondaryNodes(); diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 39b8daf8f79..cdccf23da26 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -289,15 +289,20 @@ void createIndexForApplyOps(OperationContext* opCtx, try { indexBuildsCoordinator->createIndexesOnEmptyCollection( opCtx, coll, {indexSpec}, fromMigrate); - } catch (const ExceptionFor<ErrorCodes::IndexAlreadyExists>& e) { - // Ignore the "IndexAlreadyExists" error during oplog application. - LOGV2_DEBUG(7261800, - 1, - "Ignoring indexing error", - "error"_attr = redact(e.toStatus()), - logAttrs(indexCollection->ns()), - logAttrs(indexCollection->uuid()), - "spec"_attr = indexSpec); + } catch (DBException& ex) { + // Some indexing errors can be ignored during oplog application. + const auto& status = ex.toStatus(); + if (IndexBuildsCoordinator::isCreateIndexesErrorSafeToIgnore(status, constraints)) { + LOGV2_DEBUG(7261800, + 1, + "Ignoring indexing error", + "error"_attr = redact(status), + logAttrs(indexCollection->ns()), + logAttrs(indexCollection->uuid()), + "spec"_attr = indexSpec); + return; + } + throw; } wuow.commit(); } else { |