void RollbackResyncsCollectionOptionsTest::resyncCollectionOptionsTest( CollectionOptions localCollOptions, BSONObj remoteCollOptionsObj, BSONObj collModCmd, std::string collName) { createOplog(_opCtx.get()); auto dbName = "test"; auto nss = NamespaceString(dbName, collName); auto coll = _createCollection(_opCtx.get(), nss.toString(), localCollOptions); auto commonOpUuid = unittest::assertGet(UUID::parse("f005ba11-cafe-bead-f00d-123456789abc")); auto commonOpBson = BSON("ts" << Timestamp(1, 1) << "t" << 1LL << "op" << "n" << "o" << BSONObj() << "ns" << "rollback_test.test" << "ui" << commonOpUuid); auto commonOperation = std::make_pair(commonOpBson, RecordId(1)); auto collectionModificationOperation = makeCommandOp(Timestamp(Seconds(2), 0), coll->uuid(), nss.toString(), collModCmd, 2); RollbackSourceWithCollectionOptions rollbackSource( std::unique_ptr<OplogInterface>(new OplogInterfaceMock({commonOperation})), remoteCollOptionsObj); ASSERT_OK(syncRollback(_opCtx.get(), OplogInterfaceMock({collectionModificationOperation, commonOperation}), rollbackSource, {}, _coordinator, _replicationProcess.get())); // Make sure the collection options are correct. AutoGetCollectionForReadCommand autoColl(_opCtx.get(), NamespaceString(nss.toString())); auto collAfterRollbackOptions = autoColl.getCollection()->getCatalogEntry()->getCollectionOptions(_opCtx.get()); BSONObjBuilder expectedOptionsBob; if (localCollOptions.uuid) { localCollOptions.uuid.get().appendToBuilder(&expectedOptionsBob, "uuid"); } expectedOptionsBob.appendElements(remoteCollOptionsObj); ASSERT_BSONOBJ_EQ(expectedOptionsBob.obj(), collAfterRollbackOptions.toBSON()); }
void BackgroundSync::_fallBackOnRollbackViaRefetch( OperationContext* opCtx, const HostAndPort& source, int requiredRBID, OplogInterface* localOplog, bool useUUID, OplogInterfaceRemote::GetConnectionFn getConnection) { RollbackSourceImpl rollbackSource( getConnection, source, NamespaceString::kRsOplogNamespace.ns()); if (useUUID) { rollback(opCtx, *localOplog, rollbackSource, requiredRBID, _replCoord, _replicationProcess); } else { rollbackNoUUID( opCtx, *localOplog, rollbackSource, requiredRBID, _replCoord, _replicationProcess); } }