summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2019-03-12 09:53:51 -0400
committerDianna Hohensee <dianna.hohensee@10gen.com>2019-03-12 09:53:51 -0400
commit83fa6e3879ab93549824fff82cab7030869563d0 (patch)
treeb492270544038677da915b21600de788ac470e2c /src/mongo/db/repl
parentb7007e36f6a080cb1fadeef65e768f79e091b239 (diff)
downloadmongo-83fa6e3879ab93549824fff82cab7030869563d0.tar.gz
Revert "SERVER-39079 Move BackgroundOperation checks out of the catalog layer; add parallel IndexBuildsCoordinator checks for all BackgroundOperation checks"
This reverts commit d02edd5290131978f901ffc657bee3470d03f8fd.
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/apply_ops.cpp7
-rw-r--r--src/mongo/db/repl/idempotency_test_fixture.cpp21
-rw-r--r--src/mongo/db/repl/idempotency_test_fixture.h4
-rw-r--r--src/mongo/db/repl/oplog.cpp13
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp8
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp16
7 files changed, 22 insertions, 48 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 3df073fdf83..b24fddfcfce 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -629,7 +629,6 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'drop_pending_collection_reaper',
- '$BUILD_DIR/mongo/db/index_builds_coordinator_interface',
'$BUILD_DIR/mongo/idl/server_parameter',
],
)
diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp
index e4ea07d203e..82c5717eb8a 100644
--- a/src/mongo/db/repl/apply_ops.cpp
+++ b/src/mongo/db/repl/apply_ops.cpp
@@ -46,7 +46,6 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/index_builds_coordinator.h"
#include "mongo/db/matcher/matcher.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/operation_context.h"
@@ -299,9 +298,9 @@ Status _applyPrepareTransaction(OperationContext* opCtx,
// commits.
for (const auto& opObj : info.getOperations()) {
auto ns = opObj.getField("ns").checkAndGetStringData();
- auto uuid = uassertStatusOK(UUID::parse(opObj.getField("ui")));
- BackgroundOperation::awaitNoBgOpInProgForNs(ns);
- IndexBuildsCoordinator::get(opCtx)->awaitNoIndexBuildInProgressForCollection(uuid);
+ if (BackgroundOperation::inProgForNs(ns)) {
+ BackgroundOperation::awaitNoBgOpInProgForNs(ns);
+ }
}
// Transaction operations are in its own batch, so we can modify their opCtx.
diff --git a/src/mongo/db/repl/idempotency_test_fixture.cpp b/src/mongo/db/repl/idempotency_test_fixture.cpp
index b47d798d3ee..6d12069a194 100644
--- a/src/mongo/db/repl/idempotency_test_fixture.cpp
+++ b/src/mongo/db/repl/idempotency_test_fixture.cpp
@@ -387,7 +387,7 @@ OplogEntry IdempotencyTest::update(IdType _id, const BSONObj& obj) {
OplogEntry IdempotencyTest::buildIndex(const BSONObj& indexSpec,
const BSONObj& options,
- const UUID& uuid) {
+ UUID uuid) {
BSONObjBuilder bob;
bob.append("createIndexes", nss.coll());
bob.append("v", 2);
@@ -397,9 +397,9 @@ OplogEntry IdempotencyTest::buildIndex(const BSONObj& indexSpec,
return makeCommandOplogEntry(nextOpTime(), nss, bob.obj(), uuid);
}
-OplogEntry IdempotencyTest::dropIndex(const std::string& indexName, const UUID& uuid) {
+OplogEntry IdempotencyTest::dropIndex(const std::string& indexName) {
auto cmd = BSON("dropIndexes" << nss.coll() << "index" << indexName);
- return makeCommandOplogEntry(nextOpTime(), nss, cmd, uuid);
+ return makeCommandOplogEntry(nextOpTime(), nss, cmd);
}
std::string IdempotencyTest::computeDataHash(Collection* collection) {
@@ -431,19 +431,8 @@ std::string IdempotencyTest::computeDataHash(Collection* collection) {
}
CollectionState IdempotencyTest::validate() {
- auto collUUID = [&]() -> OptionalCollectionUUID {
- AutoGetCollectionForReadCommand autoColl(_opCtx.get(), nss);
- if (auto collection = autoColl.getCollection()) {
- return collection->uuid();
- }
- return boost::none;
- }();
-
- if (collUUID) {
- // Allow in-progress indexes to complete before validating collection contents.
- IndexBuildsCoordinator::get(_opCtx.get())
- ->awaitNoIndexBuildInProgressForCollection(collUUID.get());
- }
+ // Allow in-progress indexes to complete before validating collection contents.
+ IndexBuildsCoordinator::get(_opCtx.get())->awaitNoBgOpInProgForNs(_opCtx.get(), nss);
AutoGetCollectionForReadCommand autoColl(_opCtx.get(), nss);
auto collection = autoColl.getCollection();
diff --git a/src/mongo/db/repl/idempotency_test_fixture.h b/src/mongo/db/repl/idempotency_test_fixture.h
index d86278c9810..2823f31cb41 100644
--- a/src/mongo/db/repl/idempotency_test_fixture.h
+++ b/src/mongo/db/repl/idempotency_test_fixture.h
@@ -95,8 +95,8 @@ protected:
OplogEntry insert(const BSONObj& obj);
template <class IdType>
OplogEntry update(IdType _id, const BSONObj& obj);
- OplogEntry buildIndex(const BSONObj& indexSpec, const BSONObj& options, const UUID& uuid);
- OplogEntry dropIndex(const std::string& indexName, const UUID& uuid);
+ OplogEntry buildIndex(const BSONObj& indexSpec, const BSONObj& options, UUID uuid);
+ OplogEntry dropIndex(const std::string& indexName);
virtual Status resetState();
/**
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index e45712ff716..35536687009 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -1981,7 +1981,6 @@ Status applyCommand_inlock(OperationContext* opCtx,
Lock::TempRelease release(opCtx->lockState());
BackgroundOperation::awaitNoBgOpInProgForDb(nss.db());
- IndexBuildsCoordinator::get(opCtx)->awaitNoBgOpInProgForDb(nss.db());
opCtx->recoveryUnit()->abandonSnapshot();
opCtx->checkForInterrupt();
break;
@@ -1993,16 +1992,8 @@ Status applyCommand_inlock(OperationContext* opCtx,
invariant(cmd);
// TODO: This parse could be expensive and not worth it.
- auto ns =
- cmd->parse(opCtx, OpMsgRequest::fromDBAndBody(nss.db(), o))->ns().toString();
- auto swUUID = UUID::parse(fieldUI);
- if (!swUUID.isOK()) {
- error() << "Failed command " << redact(o) << " on " << ns << " with status "
- << swUUID.getStatus() << "during oplog application. Expected a UUID.";
- }
- BackgroundOperation::awaitNoBgOpInProgForNs(ns);
- IndexBuildsCoordinator::get(opCtx)->awaitNoIndexBuildInProgressForCollection(
- swUUID.getValue());
+ BackgroundOperation::awaitNoBgOpInProgForNs(
+ cmd->parse(opCtx, OpMsgRequest::fromDBAndBody(nss.db(), o))->ns().toString());
opCtx->recoveryUnit()->abandonSnapshot();
opCtx->checkForInterrupt();
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index def645df987..f8092ab3896 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -43,7 +43,6 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/replication_state_transition_lock_guard.h"
#include "mongo/db/db_raii.h"
-#include "mongo/db/index_builds_coordinator.h"
#include "mongo/db/kill_sessions_local.h"
#include "mongo/db/logical_time_validator.h"
#include "mongo/db/operation_context.h"
@@ -376,13 +375,10 @@ Status RollbackImpl::_awaitBgIndexCompletion(OperationContext* opCtx) {
log() << "Waiting for all background operations to complete before starting rollback";
for (auto db : dbNames) {
auto numInProg = BackgroundOperation::numInProgForDb(db);
- auto numInProgInCoordinator = IndexBuildsCoordinator::get(opCtx)->numInProgForDb(db);
- if (numInProg > 0 || numInProgInCoordinator > 0) {
- LOG(1) << "Waiting for "
- << (numInProg > numInProgInCoordinator ? numInProg : numInProgInCoordinator)
+ if (numInProg > 0) {
+ LOG(1) << "Waiting for " << numInProg
<< " background operations to complete on database '" << db << "'";
BackgroundOperation::awaitNoBgOpInProgForDb(db);
- IndexBuildsCoordinator::get(opCtx)->awaitNoBgOpInProgForDb(db);
}
// Check for shutdown again.
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index 368080f8b1e..f080f656c4d 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -1101,7 +1101,7 @@ TEST_F(IdempotencyTest, Geo2dsphereIndexFailedOnIndexing) {
ASSERT_OK(runOpInitialSync(createCollection(kUuid)));
auto indexOp =
buildIndex(fromjson("{loc: '2dsphere'}"), BSON("2dsphereIndexVersion" << 3), kUuid);
- auto dropIndexOp = dropIndex("loc_index", kUuid);
+ auto dropIndexOp = dropIndex("loc_index");
auto insertOp = insert(fromjson("{_id: 1, loc: 'hi'}"));
auto ops = {indexOp, dropIndexOp, insertOp};
@@ -1174,7 +1174,7 @@ TEST_F(IdempotencyTest, IndexWithDifferentOptions) {
auto indexOp1 =
buildIndex(fromjson("{x: 'text'}"), fromjson("{default_language: 'spanish'}"), kUuid);
- auto dropIndexOp = dropIndex("x_index", kUuid);
+ auto dropIndexOp = dropIndex("x_index");
auto indexOp2 =
buildIndex(fromjson("{x: 'text'}"), fromjson("{default_language: 'english'}"), kUuid);
@@ -1209,7 +1209,7 @@ TEST_F(IdempotencyTest, InsertDocumentWithNonStringLanguageFieldWhenTextIndexExi
ASSERT_OK(runOpInitialSync(createCollection(kUuid)));
auto indexOp = buildIndex(fromjson("{x: 'text'}"), BSONObj(), kUuid);
- auto dropIndexOp = dropIndex("x_index", kUuid);
+ auto dropIndexOp = dropIndex("x_index");
auto insertOp = insert(fromjson("{_id: 1, x: 'words to index', language: 1}"));
auto ops = {indexOp, dropIndexOp, insertOp};
@@ -1243,7 +1243,7 @@ TEST_F(IdempotencyTest, InsertDocumentWithNonStringLanguageOverrideFieldWhenText
ASSERT_OK(runOpInitialSync(createCollection(kUuid)));
auto indexOp = buildIndex(fromjson("{x: 'text'}"), fromjson("{language_override: 'y'}"), kUuid);
- auto dropIndexOp = dropIndex("x_index", kUuid);
+ auto dropIndexOp = dropIndex("x_index");
auto insertOp = insert(fromjson("{_id: 1, x: 'words to index', y: 1}"));
auto ops = {indexOp, dropIndexOp, insertOp};
@@ -1411,8 +1411,8 @@ TEST_F(IdempotencyTest, CollModNamespaceNotFound) {
auto indexChange = fromjson("{keyPattern: {createdAt:1}, expireAfterSeconds:4000}}");
auto collModCmd = BSON("collMod" << nss.coll() << "index" << indexChange);
- auto collModOp = makeCommandOplogEntry(nextOpTime(), nss, collModCmd, kUuid);
- auto dropCollOp = makeCommandOplogEntry(nextOpTime(), nss, BSON("drop" << nss.coll()), kUuid);
+ auto collModOp = makeCommandOplogEntry(nextOpTime(), nss, collModCmd);
+ auto dropCollOp = makeCommandOplogEntry(nextOpTime(), nss, BSON("drop" << nss.coll()));
auto ops = {collModOp, dropCollOp};
testOpsAreIdempotent(ops);
@@ -1428,8 +1428,8 @@ TEST_F(IdempotencyTest, CollModIndexNotFound) {
auto indexChange = fromjson("{keyPattern: {createdAt:1}, expireAfterSeconds:4000}}");
auto collModCmd = BSON("collMod" << nss.coll() << "index" << indexChange);
- auto collModOp = makeCommandOplogEntry(nextOpTime(), nss, collModCmd, kUuid);
- auto dropIndexOp = dropIndex("createdAt_index", kUuid);
+ auto collModOp = makeCommandOplogEntry(nextOpTime(), nss, collModCmd);
+ auto dropIndexOp = dropIndex("createdAt_index");
auto ops = {collModOp, dropIndexOp};
testOpsAreIdempotent(ops);