summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/rollback_test_fixture.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2018-10-04 18:27:48 -0400
committerDavid Storch <david.storch@10gen.com>2018-10-23 17:18:11 -0400
commit2cdc2a96e1c8779658fe0eab459dcc38cf01c54d (patch)
tree875f55acaaba283f02895938ee4b6c764eac349a /src/mongo/db/repl/rollback_test_fixture.cpp
parente7bed9bdcb376d5a06dce6228047309e8481f9cf (diff)
downloadmongo-2cdc2a96e1c8779658fe0eab459dcc38cf01c54d.tar.gz
SERVER-37443 Make catalog objects survive collection rename.
This change only applies to collection renames within the same database. Rename across databases requires copying the data, and the resulting collection will have a new UUID.
Diffstat (limited to 'src/mongo/db/repl/rollback_test_fixture.cpp')
-rw-r--r--src/mongo/db/repl/rollback_test_fixture.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp
index 4b1fa5f93b4..fefed34d53f 100644
--- a/src/mongo/db/repl/rollback_test_fixture.cpp
+++ b/src/mongo/db/repl/rollback_test_fixture.cpp
@@ -38,6 +38,8 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/client.h"
#include "mongo/db/db_raii.h"
+#include "mongo/db/op_observer_noop.h"
+#include "mongo/db/op_observer_registry.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/replication_consistency_markers_mock.h"
#include "mongo/db/repl/replication_coordinator.h"
@@ -48,7 +50,6 @@
#include "mongo/db/session_catalog.h"
#include "mongo/logger/log_component.h"
#include "mongo/logger/logger.h"
-
#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
@@ -67,6 +68,23 @@ ReplSettings createReplSettings() {
return settings;
}
+class RollbackTestOpObserver : public OpObserverNoop {
+public:
+ repl::OpTime onDropCollection(OperationContext* opCtx,
+ const NamespaceString& collectionName,
+ OptionalCollectionUUID uuid,
+ const CollectionDropType dropType) override {
+ // If the oplog is not disabled for this namespace, then we need to reserve an op time for
+ // the drop.
+ if (!repl::ReplicationCoordinator::get(opCtx)->isOplogDisabledFor(opCtx, collectionName)) {
+ OpObserver::Times::get(opCtx).reservedOpTimes.push_back(dropOpTime);
+ }
+ return {};
+ }
+
+ const repl::OpTime dropOpTime = {Timestamp(Seconds(100), 1U), 1LL};
+};
+
} // namespace
void RollbackTest::setUp() {
@@ -94,6 +112,9 @@ void RollbackTest::setUp() {
// Increase rollback log component verbosity for unit tests.
mongo::logger::globalLogDomain()->setMinimumLoggedSeverity(
logger::LogComponent::kReplicationRollback, logger::LogSeverity::Debug(2));
+
+ auto observerRegistry = checked_cast<OpObserverRegistry*>(serviceContext->getOpObserver());
+ observerRegistry->addObserver(std::make_unique<RollbackTestOpObserver>());
}
RollbackTest::ReplicationCoordinatorRollbackMock::ReplicationCoordinatorRollbackMock(