summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-03-30 14:30:44 -0400
committerBenety Goh <benety@mongodb.com>2018-03-30 14:30:44 -0400
commit149f69b84042ff4cbdc53559c746feb8f948273e (patch)
tree7485d97b15856db0693ff2c8470c8a7734ce237d
parentfbbdb5643a3fab20a4c7875830382748a4ba75e4 (diff)
downloadmongo-149f69b84042ff4cbdc53559c746feb8f948273e.tar.gz
SERVER-34196 remove redundant dropTarget boolean argument from OpObserver::onRenameCollection
-rw-r--r--src/mongo/db/catalog/create_collection.cpp2
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp6
-rw-r--r--src/mongo/db/catalog/rename_collection_test.cpp14
-rw-r--r--src/mongo/db/catalog/uuid_catalog.cpp1
-rw-r--r--src/mongo/db/catalog/uuid_catalog.h1
-rw-r--r--src/mongo/db/op_observer.h1
-rw-r--r--src/mongo/db/op_observer_impl.cpp3
-rw-r--r--src/mongo/db/op_observer_impl.h1
-rw-r--r--src/mongo/db/op_observer_impl_test.cpp3
-rw-r--r--src/mongo/db/op_observer_noop.h1
-rw-r--r--src/mongo/db/op_observer_registry.h3
-rw-r--r--src/mongo/db/op_observer_registry_test.cpp5
-rw-r--r--src/mongo/db/s/config_server_op_observer.h1
-rw-r--r--src/mongo/db/s/shard_server_op_observer.h1
14 files changed, 14 insertions, 29 deletions
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp
index ebd43cc24b9..fa79289254b 100644
--- a/src/mongo/db/catalog/create_collection.cpp
+++ b/src/mongo/db/catalog/create_collection.cpp
@@ -207,7 +207,6 @@ Status createCollectionForApplyOps(OperationContext* opCtx,
newCollName,
tmpName,
futureColl->uuid(),
- /*dropTarget*/ false,
/*dropTargetUUID*/ {},
stayTemp);
}
@@ -228,7 +227,6 @@ Status createCollectionForApplyOps(OperationContext* opCtx,
currentName,
newCollName,
uuid,
- /*dropTarget*/ false,
/*dropTargetUUID*/ {},
stayTemp);
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index 6affb8773f3..a5d26422d2a 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -245,8 +245,7 @@ Status renameCollectionCommon(OperationContext* opCtx,
// We have to override the provided 'dropTarget' setting for idempotency reasons to
// avoid unintentionally removing a collection on a secondary with the same name as
// the target.
- opObserver->onRenameCollection(
- opCtx, source, target, sourceUUID, false, {}, stayTemp);
+ opObserver->onRenameCollection(opCtx, source, target, sourceUUID, {}, stayTemp);
wunit.commit();
return Status::OK();
}
@@ -254,8 +253,9 @@ Status renameCollectionCommon(OperationContext* opCtx,
// Target collection exists - drop it.
invariant(options.dropTarget);
auto dropTargetUUID = targetColl->uuid();
+ invariant(dropTargetUUID);
auto renameOpTime = opObserver->onRenameCollection(
- opCtx, source, target, sourceUUID, true, dropTargetUUID, options.stayTemp);
+ opCtx, source, target, sourceUUID, dropTargetUUID, options.stayTemp);
if (!renameOpTimeFromApplyOps.isNull()) {
// 'renameOpTime' must be null because a valid 'renameOpTimeFromApplyOps' implies
diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp
index f6edde5f062..f72f686aaa5 100644
--- a/src/mongo/db/catalog/rename_collection_test.cpp
+++ b/src/mongo/db/catalog/rename_collection_test.cpp
@@ -98,7 +98,6 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) override;
@@ -110,7 +109,7 @@ public:
bool onInsertsIsGlobalWriteLockExclusive = false;
bool onRenameCollectionCalled = false;
- bool onRenameCollectionDropTarget = false;
+ OptionalCollectionUUID onRenameCollectionDropTarget;
repl::OpTime renameOpTime = {Timestamp(Seconds(100), 1U), 1LL};
private:
@@ -172,15 +171,14 @@ repl::OpTime OpObserverMock::onRenameCollection(OperationContext* opCtx,
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) {
_logOp(opCtx, fromCollection, "rename");
OpObserver::Times::get(opCtx).reservedOpTimes.push_back(renameOpTime);
OpObserverNoop::onRenameCollection(
- opCtx, fromCollection, toCollection, uuid, dropTarget, dropTargetUUID, stayTemp);
+ opCtx, fromCollection, toCollection, uuid, dropTargetUUID, stayTemp);
onRenameCollectionCalled = true;
- onRenameCollectionDropTarget = dropTarget;
+ onRenameCollectionDropTarget = dropTargetUUID;
return {};
}
@@ -666,8 +664,8 @@ TEST_F(RenameCollectionTest,
}
TEST_F(RenameCollectionTest, RenameCollectionMakesTargetCollectionDropPendingIfDropTargetIsTrue) {
- _createCollection(_opCtx.get(), _sourceNss);
- _createCollection(_opCtx.get(), _targetNss);
+ _createCollectionWithUUID(_opCtx.get(), _sourceNss);
+ auto targetUUID = _createCollectionWithUUID(_opCtx.get(), _targetNss);
RenameCollectionOptions options;
options.dropTarget = true;
ASSERT_OK(renameCollection(_opCtx.get(), _sourceNss, _targetNss, options));
@@ -677,7 +675,7 @@ TEST_F(RenameCollectionTest, RenameCollectionMakesTargetCollectionDropPendingIfD
<< " missing after successful rename";
ASSERT_TRUE(_opObserver->onRenameCollectionCalled);
- ASSERT_TRUE(_opObserver->onRenameCollectionDropTarget);
+ ASSERT_EQUALS(targetUUID, _opObserver->onRenameCollectionDropTarget);
auto renameOpTime = _opObserver->renameOpTime;
ASSERT_GREATER_THAN(renameOpTime, repl::OpTime());
diff --git a/src/mongo/db/catalog/uuid_catalog.cpp b/src/mongo/db/catalog/uuid_catalog.cpp
index e3d30458810..15edc59c320 100644
--- a/src/mongo/db/catalog/uuid_catalog.cpp
+++ b/src/mongo/db/catalog/uuid_catalog.cpp
@@ -86,7 +86,6 @@ repl::OpTime UUIDCatalogObserver::onRenameCollection(OperationContext* opCtx,
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) {
diff --git a/src/mongo/db/catalog/uuid_catalog.h b/src/mongo/db/catalog/uuid_catalog.h
index 1bff9662da0..57a6061df39 100644
--- a/src/mongo/db/catalog/uuid_catalog.h
+++ b/src/mongo/db/catalog/uuid_catalog.h
@@ -93,7 +93,6 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) override;
void onApplyOps(OperationContext* opCtx,
diff --git a/src/mongo/db/op_observer.h b/src/mongo/db/op_observer.h
index f6116324eee..d65bb57bb7b 100644
--- a/src/mongo/db/op_observer.h
+++ b/src/mongo/db/op_observer.h
@@ -222,7 +222,6 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) = 0;
virtual void onApplyOps(OperationContext* opCtx,
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index c3216b51715..999c494969c 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -754,7 +754,6 @@ repl::OpTime OpObserverImpl::onRenameCollection(OperationContext* const opCtx,
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) {
const auto cmdNss = fromCollection.getCommandNS();
@@ -766,7 +765,7 @@ repl::OpTime OpObserverImpl::onRenameCollection(OperationContext* const opCtx,
if (dropTargetUUID) {
dropTargetUUID->appendToBuilder(&builder, "dropTarget");
} else {
- builder.append("dropTarget", dropTarget);
+ builder.append("dropTarget", false);
}
const auto cmdObj = builder.done();
diff --git a/src/mongo/db/op_observer_impl.h b/src/mongo/db/op_observer_impl.h
index 8c30965478e..4d62e4d8b3a 100644
--- a/src/mongo/db/op_observer_impl.h
+++ b/src/mongo/db/op_observer_impl.h
@@ -89,7 +89,6 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) override;
void onApplyOps(OperationContext* opCtx,
diff --git a/src/mongo/db/op_observer_impl_test.cpp b/src/mongo/db/op_observer_impl_test.cpp
index 91937db07b5..9c405be54ba 100644
--- a/src/mongo/db/op_observer_impl_test.cpp
+++ b/src/mongo/db/op_observer_impl_test.cpp
@@ -230,8 +230,7 @@ TEST_F(OpObserverTest, OnRenameCollectionReturnsRenameOpTime) {
{
AutoGetDb autoDb(opCtx.get(), sourceNss.db(), MODE_X);
WriteUnitOfWork wunit(opCtx.get());
- opObserver.onRenameCollection(
- opCtx.get(), sourceNss, targetNss, {}, dropTarget, {}, stayTemp);
+ opObserver.onRenameCollection(opCtx.get(), sourceNss, targetNss, {}, {}, stayTemp);
renameOpTime = OpObserver::Times::get(opCtx.get()).reservedOpTimes.front();
wunit.commit();
}
diff --git a/src/mongo/db/op_observer_noop.h b/src/mongo/db/op_observer_noop.h
index 611ac2d006f..67682888d1a 100644
--- a/src/mongo/db/op_observer_noop.h
+++ b/src/mongo/db/op_observer_noop.h
@@ -86,7 +86,6 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) override {
return {};
diff --git a/src/mongo/db/op_observer_registry.h b/src/mongo/db/op_observer_registry.h
index 4fd69ca2645..d02025ffd98 100644
--- a/src/mongo/db/op_observer_registry.h
+++ b/src/mongo/db/op_observer_registry.h
@@ -164,13 +164,12 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) override {
ReservedTimes times{opCtx};
for (auto& observer : this->_observers) {
const auto time = observer->onRenameCollection(
- opCtx, fromCollection, toCollection, uuid, dropTarget, dropTargetUUID, stayTemp);
+ opCtx, fromCollection, toCollection, uuid, dropTargetUUID, stayTemp);
invariant(time.isNull());
}
diff --git a/src/mongo/db/op_observer_registry_test.cpp b/src/mongo/db/op_observer_registry_test.cpp
index 5589860e1e7..445c4789aab 100644
--- a/src/mongo/db/op_observer_registry_test.cpp
+++ b/src/mongo/db/op_observer_registry_test.cpp
@@ -63,7 +63,6 @@ struct TestObserver : public OpObserverNoop {
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) {
OpObserver::Times::get(opCtx).reservedOpTimes.push_back(opTime);
@@ -162,7 +161,7 @@ TEST_F(OpObserverRegistryTest, OnRenameCollectionObserverResultReturnsRightTime)
registry.addObserver(std::move(unique1));
registry.addObserver(std::make_unique<OpObserverNoop>());
auto op = [&]() -> repl::OpTime {
- return registry.onRenameCollection(&opCtx, testNss, testNss, {}, false, {}, false);
+ return registry.onRenameCollection(&opCtx, testNss, testNss, {}, {}, false);
};
checkConsistentOpTime(op);
}
@@ -180,7 +179,7 @@ DEATH_TEST_F(OpObserverRegistryTest, OnRenameCollectionReturnsInconsistentTime,
registry.addObserver(std::move(unique1));
registry.addObserver(std::move(unique2));
auto op = [&]() -> repl::OpTime {
- return registry.onRenameCollection(&opCtx, testNss, testNss, {}, false, {}, false);
+ return registry.onRenameCollection(&opCtx, testNss, testNss, {}, {}, false);
};
checkInconsistentOpTime(op);
}
diff --git a/src/mongo/db/s/config_server_op_observer.h b/src/mongo/db/s/config_server_op_observer.h
index 58bb08c7ecd..d2e60094f7d 100644
--- a/src/mongo/db/s/config_server_op_observer.h
+++ b/src/mongo/db/s/config_server_op_observer.h
@@ -105,7 +105,6 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) override {
return repl::OpTime();
diff --git a/src/mongo/db/s/shard_server_op_observer.h b/src/mongo/db/s/shard_server_op_observer.h
index 89c42a411a6..4bccaacc3d9 100644
--- a/src/mongo/db/s/shard_server_op_observer.h
+++ b/src/mongo/db/s/shard_server_op_observer.h
@@ -105,7 +105,6 @@ public:
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
OptionalCollectionUUID uuid,
- bool dropTarget,
OptionalCollectionUUID dropTargetUUID,
bool stayTemp) override {
return repl::OpTime();