diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2018-05-02 16:28:34 -0400 |
---|---|---|
committer | Suganthi Mani <suganthi.mani@mongodb.com> | 2018-05-07 18:23:35 -0400 |
commit | b8ec2b195ba2a6e024fa80ec85547f7a670e6df3 (patch) | |
tree | 95b84c5fead7177863b594abbb98a76936bf7895 /src/mongo/db/repl/rs_rollback_test.cpp | |
parent | 79da069140feb5a62cb46640267c887d19d63e6c (diff) | |
download | mongo-b8ec2b195ba2a6e024fa80ec85547f7a670e6df3.tar.gz |
SERVER-34110 Ignore NamespaceNotFound errors when refetching documents during rollback
Diffstat (limited to 'src/mongo/db/repl/rs_rollback_test.cpp')
-rw-r--r-- | src/mongo/db/repl/rs_rollback_test.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index 93a47ec8044..4573e277d83 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -314,7 +314,8 @@ int _testRollbackDelete(OperationContext* opCtx, ReplicationCoordinator* coordinator, ReplicationProcess* replicationProcess, UUID uuid, - const BSONObj& documentAtSource) { + const BSONObj& documentAtSource, + const bool collectionAtSourceExists = true) { auto commonOperation = makeOpAndRecordId(1, 1); auto deleteOperation = std::make_pair(BSON("ts" << Timestamp(Seconds(2), 0) << "h" << 2LL << "op" @@ -328,25 +329,35 @@ int _testRollbackDelete(OperationContext* opCtx, RecordId(2)); class RollbackSourceLocal : public RollbackSourceMock { public: - RollbackSourceLocal(const BSONObj& documentAtSource, std::unique_ptr<OplogInterface> oplog) + RollbackSourceLocal(const BSONObj& documentAtSource, + std::unique_ptr<OplogInterface> oplog, + const bool collectionAtSourceExists) : RollbackSourceMock(std::move(oplog)), called(false), - _documentAtSource(documentAtSource) {} + _documentAtSource(documentAtSource), + _collectionAtSourceExists(collectionAtSourceExists) {} std::pair<BSONObj, NamespaceString> findOneByUUID(const std::string& db, UUID uuid, const BSONObj& filter) const override { called = true; + if (!_collectionAtSourceExists) { + uassertStatusOKWithContext( + Status(ErrorCodes::NamespaceNotFound, "MockNamespaceNotFoundMsg"), + "find command using UUID failed."); + } return {_documentAtSource, NamespaceString()}; } mutable bool called; private: BSONObj _documentAtSource; + bool _collectionAtSourceExists; }; RollbackSourceLocal rollbackSource(documentAtSource, std::unique_ptr<OplogInterface>(new OplogInterfaceMock({ commonOperation, - }))); + })), + collectionAtSourceExists); ASSERT_OK(syncRollback(opCtx, OplogInterfaceMock({deleteOperation, commonOperation}), rollbackSource, @@ -374,6 +385,24 @@ TEST_F(RSRollbackTest, RollbackDeleteNoDocumentAtSourceCollectionDoesNotExist) { _opCtx.get(), _coordinator, _replicationProcess.get(), UUID::gen(), BSONObj())); } +TEST_F(RSRollbackTest, RollbackDeleteDocCmdCollectionAtSourceDropped) { + const bool collectionAtSourceExists = false; + const NamespaceString nss("test.t"); + createOplog(_opCtx.get()); + { + Lock::DBLock dbLock(_opCtx.get(), nss.db(), MODE_X); + auto db = DatabaseHolder::getDatabaseHolder().openDb(_opCtx.get(), nss.db()); + ASSERT_TRUE(db); + } + ASSERT_EQUALS(-1, + _testRollbackDelete(_opCtx.get(), + _coordinator, + _replicationProcess.get(), + UUID::gen(), + BSONObj(), + collectionAtSourceExists)); +} + TEST_F(RSRollbackTest, RollbackDeleteNoDocumentAtSourceCollectionExistsNonCapped) { createOplog(_opCtx.get()); CollectionOptions options; |