diff options
author | Cheahuychou Mao <cheahuychou.mao@mongodb.com> | 2020-08-25 21:18:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-28 23:40:27 +0000 |
commit | 7b0f4781f878fc7c231c2a1ed7fc20fd9ca1a1e6 (patch) | |
tree | bea15f7b4213cb060907b526794acafd0d71ae35 /src/mongo | |
parent | caf0451c59b3a9304743ed82c05d13052600407d (diff) | |
download | mongo-7b0f4781f878fc7c231c2a1ed7fc20fd9ca1a1e6.tar.gz |
SERVER-50104 Make the test hook run a background migration on the data used by tests
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/repl/apply_ops.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 24 | ||||
-rw-r--r-- | src/mongo/shell/bulk_api.js | 2 |
3 files changed, 22 insertions, 6 deletions
diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp index 7e590f14580..076146c191f 100644 --- a/src/mongo/db/repl/apply_ops.cpp +++ b/src/mongo/db/repl/apply_ops.cpp @@ -260,7 +260,7 @@ Status _applyOps(OperationContext* opCtx, result->append("codeName", ErrorCodes::errorString(ex.code())); result->append("errmsg", ex.what()); result->append("results", ab.arr()); - return Status(ex.code(), ex.what()); + return ex.toStatus(); } } diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 1ed66938941..58133d54a59 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -229,10 +229,26 @@ void _logOpsInner(OperationContext* opCtx, uasserted(ErrorCodes::NotMaster, ss); } - // The oplogEntry for renameCollection has nss set to the fromCollection's ns. renameCollection - // can be across databases, but a tenant will never be able to rename into a database with a - // different prefix, so it is safe to use the fromCollection's db's prefix for this check. - tenant_migration_donor::onWriteToDatabase(opCtx, nss.db()); + // TODO (SERVER-50598): Not allow tenant migration donor to write "commitIndexBuild" and + // "abortIndexBuild" oplog entries in the blocking state. + // Allow that for now since if the donor doesn't write either a commit or abort oplog entry, + // some resources will not be released on the donor nodes, and this can lead to deadlocks. + auto isCommitOrAbortIndexBuild = + std::any_of(records->begin(), records->end(), [](Record record) { + auto o = record.data.toBson().getObjectField("o"); + return o.hasField("commitIndexBuild") || o.hasField("abortIndexBuild"); + }); + + if (!isCommitOrAbortIndexBuild) { + // Throw TenantMigrationConflict error if the database for 'nss' is being migrated. + // The oplog entry for renameCollection has 'nss' set to the fromCollection's ns. + // renameCollection can be across databases, but a tenant will never be able to rename into + // a database with a different prefix, so it is safe to use the fromCollection's db's prefix + // for this check. + tenant_migration_donor::onWriteToDatabase(opCtx, nss.db()); + } else { + invariant(records->size() == 1); + } Status result = oplogCollection->insertDocumentsForOplog(opCtx, records, timestamps); if (!result.isOK()) { diff --git a/src/mongo/shell/bulk_api.js b/src/mongo/shell/bulk_api.js index 0b880175648..61b89819b69 100644 --- a/src/mongo/shell/bulk_api.js +++ b/src/mongo/shell/bulk_api.js @@ -536,7 +536,7 @@ var _bulk_api_module = (function() { // Set max byte size var maxBatchSizeBytes = 1024 * 1024 * 16; - var maxNumberOfDocsInBatch = 1000; + var maxNumberOfDocsInBatch = (TestData && TestData.disableBatchWrites) ? 1 : 1000; var writeConcern = null; var currentOp; |