diff options
| author | clang-format 12.0.1 <> | 2023-02-10 04:44:29 -0800 |
|---|---|---|
| committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-11 08:00:01 +0000 |
| commit | f63255ee677ecae5896d6f35dd712ed60ae8c39a (patch) | |
| tree | 97ffffa8d6f9e1a131aeb1ccc1d42f133f8407fd /src/mongo/db/repl | |
| parent | 375366e3f317d18717df24f861b09c4d2f8fb27f (diff) | |
| download | mongo-f63255ee677ecae5896d6f35dd712ed60ae8c39a.tar.gz | |
SERVER-72197 Run clang-format 12.0.1 on the codebase
Signed-off-by: Ryan Egesdahl <ryan.egesdahl@mongodb.com>
Diffstat (limited to 'src/mongo/db/repl')
42 files changed, 363 insertions, 207 deletions
diff --git a/src/mongo/db/repl/abstract_async_component_test.cpp b/src/mongo/db/repl/abstract_async_component_test.cpp index a8ee5248bf6..bd126bd7ecf 100644 --- a/src/mongo/db/repl/abstract_async_component_test.cpp +++ b/src/mongo/db/repl/abstract_async_component_test.cpp @@ -351,7 +351,8 @@ TEST_F(AbstractAsyncComponentTest, component.shutdown(); ASSERT_EQUALS(AbstractAsyncComponent::State::kShuttingDown, component.getState_forTest()); - auto callback = [](const executor::TaskExecutor::CallbackArgs&) {}; + auto callback = [](const executor::TaskExecutor::CallbackArgs&) { + }; executor::TaskExecutor::CallbackHandle handle; ASSERT_EQUALS(ErrorCodes::CallbackCanceled, component.scheduleWorkAndSaveHandle_forTest(callback, &handle, "mytask")); @@ -362,9 +363,12 @@ TEST_F(AbstractAsyncComponentTest, TaskExecutorMock taskExecutorMock(&getExecutor()); MockAsyncComponent component(&taskExecutorMock); - taskExecutorMock.shouldFailScheduleWorkRequest = []() { return true; }; + taskExecutorMock.shouldFailScheduleWorkRequest = []() { + return true; + }; - auto callback = [](const executor::TaskExecutor::CallbackArgs&) {}; + auto callback = [](const executor::TaskExecutor::CallbackArgs&) { + }; executor::TaskExecutor::CallbackHandle handle; ASSERT_EQUALS(ErrorCodes::OperationFailed, component.scheduleWorkAndSaveHandle_forTest(callback, &handle, "mytask")); @@ -394,7 +398,8 @@ TEST_F(AbstractAsyncComponentTest, ASSERT_EQUALS(AbstractAsyncComponent::State::kShuttingDown, component.getState_forTest()); auto when = getExecutor().now() + Seconds(1); - auto callback = [](const executor::TaskExecutor::CallbackArgs&) {}; + auto callback = [](const executor::TaskExecutor::CallbackArgs&) { + }; executor::TaskExecutor::CallbackHandle handle; ASSERT_EQUALS(ErrorCodes::CallbackCanceled, component.scheduleWorkAtAndSaveHandle_forTest(when, callback, &handle, "mytask")); @@ -405,10 +410,13 @@ TEST_F(AbstractAsyncComponentTest, TaskExecutorMock taskExecutorMock(&getExecutor()); MockAsyncComponent component(&taskExecutorMock); - taskExecutorMock.shouldFailScheduleWorkAtRequest = []() { return true; }; + taskExecutorMock.shouldFailScheduleWorkAtRequest = []() { + return true; + }; auto when = getExecutor().now() + Seconds(1); - auto callback = [](const executor::TaskExecutor::CallbackArgs&) {}; + auto callback = [](const executor::TaskExecutor::CallbackArgs&) { + }; executor::TaskExecutor::CallbackHandle handle; ASSERT_EQUALS(ErrorCodes::OperationFailed, component.scheduleWorkAtAndSaveHandle_forTest(when, callback, &handle, "mytask")); diff --git a/src/mongo/db/repl/cloner_test_fixture.cpp b/src/mongo/db/repl/cloner_test_fixture.cpp index b37dc27059f..0cdbd27b18a 100644 --- a/src/mongo/db/repl/cloner_test_fixture.cpp +++ b/src/mongo/db/repl/cloner_test_fixture.cpp @@ -65,7 +65,9 @@ void ClonerTestFixture::setUp() { ThreadPool::Options options; options.minThreads = 1U; options.maxThreads = 1U; - options.onCreateThread = [](StringData threadName) { Client::initThread(threadName); }; + options.onCreateThread = [](StringData threadName) { + Client::initThread(threadName); + }; _dbWorkThreadPool = std::make_unique<ThreadPool>(options); _dbWorkThreadPool->startup(); _source = HostAndPort{"local:1234"}; diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp index 9fa0a179464..b5d3af1b6b5 100644 --- a/src/mongo/db/repl/collection_cloner.cpp +++ b/src/mongo/db/repl/collection_cloner.cpp @@ -90,9 +90,9 @@ CollectionCloner::CollectionCloner(const NamespaceString& sourceNss, "documents copied", str::stream() << _sourceNss.toString() << " collection clone progress"), _scheduleDbWorkFn([this](executor::TaskExecutor::CallbackFn work) { - auto task = [ this, work = std::move(work) ]( - OperationContext * opCtx, - const Status& status) mutable noexcept->TaskRunner::NextAction { + auto task = [this, work = std::move(work)]( + OperationContext* opCtx, + const Status& status) mutable noexcept -> TaskRunner::NextAction { try { work(executor::TaskExecutor::CallbackArgs(nullptr, {}, status, opCtx)); } catch (const DBException& e) { diff --git a/src/mongo/db/repl/drop_pending_collection_reaper.cpp b/src/mongo/db/repl/drop_pending_collection_reaper.cpp index 6b4e4dc7051..bf535bd4a2d 100644 --- a/src/mongo/db/repl/drop_pending_collection_reaper.cpp +++ b/src/mongo/db/repl/drop_pending_collection_reaper.cpp @@ -139,7 +139,9 @@ bool DropPendingCollectionReaper::rollBackDropPendingCollection( const auto equalRange = _dropPendingNamespaces.equal_range(opTime); const auto& lowerBound = equalRange.first; const auto& upperBound = equalRange.second; - auto matcher = [&pendingNss](const auto& pair) { return pair.second == pendingNss; }; + auto matcher = [&pendingNss](const auto& pair) { + return pair.second == pendingNss; + }; auto it = std::find_if(lowerBound, upperBound, matcher); if (it == upperBound) { LOGV2_WARNING(21154, diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index cd562d19af5..c6183c429b5 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -629,7 +629,9 @@ void InitialSyncer::_startInitialSyncAttemptCallback( "initialSyncMaxAttempts"_attr = initialSyncMaxAttempts); // This completion guard invokes _finishInitialSyncAttempt on destruction. - auto cancelRemainingWorkInLock = [this]() { _cancelRemainingWork_inlock(); }; + auto cancelRemainingWorkInLock = [this]() { + _cancelRemainingWork_inlock(); + }; auto finishInitialSyncAttemptFn = [this](const StatusWith<OpTimeAndWallTime>& lastApplied) { _finishInitialSyncAttempt(lastApplied); }; diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp index 0245fe9b5c8..68dcc639166 100644 --- a/src/mongo/db/repl/initial_syncer_test.cpp +++ b/src/mongo/db/repl/initial_syncer_test.cpp @@ -411,11 +411,15 @@ protected: InitialSyncerInterface::Options options; options.initialSyncRetryWait = Milliseconds(1); - options.getMyLastOptime = [this]() { return _myLastOpTime; }; + options.getMyLastOptime = [this]() { + return _myLastOpTime; + }; options.setMyLastOptime = [this](const OpTimeAndWallTime& opTimeAndWallTime) { _setMyLastOptime(opTimeAndWallTime); }; - options.resetOptimes = [this]() { _myLastOpTime = OpTime(); }; + options.resetOptimes = [this]() { + _myLastOpTime = OpTime(); + }; options.syncSourceSelector = this; _options = options; @@ -550,13 +554,17 @@ private: executor::ThreadPoolMock::Options InitialSyncerTest::makeThreadPoolMockOptions() const { executor::ThreadPoolMock::Options options; - options.onCreateThread = []() { Client::initThread("InitialSyncerTest"); }; + options.onCreateThread = []() { + Client::initThread("InitialSyncerTest"); + }; return options; } executor::ThreadPoolMock::Options InitialSyncerTest::makeClonerThreadPoolMockOptions() const { executor::ThreadPoolMock::Options options; - options.onCreateThread = []() { Client::initThread("ClonerThreadTest"); }; + options.onCreateThread = []() { + Client::initThread("ClonerThreadTest"); + }; return options; } @@ -701,11 +709,16 @@ void InitialSyncerTest::processSuccessfulFCVFetcherResponse(std::vector<BSONObj> TEST_F(InitialSyncerTest, InvalidConstruction) { InitialSyncerInterface::Options options; - options.getMyLastOptime = []() { return OpTime(); }; - options.setMyLastOptime = [](const OpTimeAndWallTime&) {}; - options.resetOptimes = []() {}; + options.getMyLastOptime = []() { + return OpTime(); + }; + options.setMyLastOptime = [](const OpTimeAndWallTime&) { + }; + options.resetOptimes = []() { + }; options.syncSourceSelector = this; - auto callback = [](const StatusWith<OpTimeAndWallTime>&) {}; + auto callback = [](const StatusWith<OpTimeAndWallTime>&) { + }; // Null task executor in external state. { @@ -990,7 +1003,9 @@ TEST_F(InitialSyncerTest, auto opCtx = makeOpCtx(); _syncSourceSelector->setChooseNewSyncSourceResult_forTest(HostAndPort()); - _executorProxy->shouldFailScheduleWorkAtRequest = []() { return true; }; + _executorProxy->shouldFailScheduleWorkAtRequest = []() { + return true; + }; ASSERT_OK(initialSyncer->startup(opCtx.get(), maxAttempts)); initialSyncer->join(); @@ -1016,7 +1031,9 @@ TEST_F(InitialSyncerTest, // Last choose sync source attempt should now be scheduled. Advance clock so we fail last // choose sync source attempt which cause the next initial sync attempt to be scheduled. - _executorProxy->shouldFailScheduleWorkAtRequest = []() { return true; }; + _executorProxy->shouldFailScheduleWorkAtRequest = []() { + return true; + }; advanceClock(net, _options.syncSourceRetryWait); initialSyncer->join(); @@ -3693,7 +3710,9 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughGetNextApplierBatchScheduleE // Before processing scheduled last oplog entry fetcher response, set flag in // TaskExecutorMock so that InitialSyncer will fail to schedule // _getNextApplierBatchCallback(). - _executorProxy->shouldFailScheduleWorkRequest = []() { return true; }; + _executorProxy->shouldFailScheduleWorkRequest = []() { + return true; + }; // Oplog entry associated with the stopTimestamp. processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(2)}); @@ -3750,7 +3769,9 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughSecondGetNextApplierBatchSch // Before processing scheduled last oplog entry fetcher response, set flag in // TaskExecutorMock so that InitialSyncer will fail to schedule second // _getNextApplierBatchCallback() at (now + options.getApplierBatchCallbackRetryWait). - _executorProxy->shouldFailScheduleWorkAtRequest = []() { return true; }; + _executorProxy->shouldFailScheduleWorkAtRequest = []() { + return true; + }; // Oplog entry associated with the stopTimestamp. processSuccessfulLastOplogEntryFetcherResponse({makeOplogEntryObj(2)}); @@ -4003,7 +4024,9 @@ TEST_F(InitialSyncerTest, InitialSyncerPassesThroughMultiApplierScheduleError) { getOplogFetcher()->receiveBatch(1LL, {makeOplogEntryObj(1), makeOplogEntryObj(2)}); // Make MultiApplier::startup() fail. - _executorProxy->shouldFailScheduleWorkRequest = []() { return true; }; + _executorProxy->shouldFailScheduleWorkRequest = []() { + return true; + }; // Advance clock until _getNextApplierBatchCallback() runs. auto when = net->now() + _options.getApplierBatchCallbackRetryWait; diff --git a/src/mongo/db/repl/multiapplier_test.cpp b/src/mongo/db/repl/multiapplier_test.cpp index 5119f14a85d..41ebf999c91 100644 --- a/src/mongo/db/repl/multiapplier_test.cpp +++ b/src/mongo/db/repl/multiapplier_test.cpp @@ -52,7 +52,9 @@ private: executor::ThreadPoolMock::Options MultiApplierTest::makeThreadPoolMockOptions() const { executor::ThreadPoolMock::Options options; - options.onCreateThread = []() { Client::initThread("MultiApplierTest"); }; + options.onCreateThread = []() { + Client::initThread("MultiApplierTest"); + }; return options; } @@ -91,7 +93,8 @@ TEST_F(MultiApplierTest, InvalidConstruction) { auto multiApply = [](OperationContext*, std::vector<OplogEntry>) -> StatusWith<OpTime> { return Status(ErrorCodes::InternalError, "not implemented"); }; - auto callback = [](const Status&) {}; + auto callback = [](const Status&) { + }; // Null executor. ASSERT_THROWS_CODE_AND_WHAT(MultiApplier(nullptr, operations, multiApply, callback), @@ -127,7 +130,8 @@ TEST_F(MultiApplierTest, MultiApplierTransitionsDirectlyToCompleteIfShutdownBefo auto multiApply = [](OperationContext*, std::vector<OplogEntry>) -> StatusWith<OpTime> { return OpTime(); }; - auto callback = [](const Status&) {}; + auto callback = [](const Status&) { + }; MultiApplier multiApplier(&getExecutor(), operations, multiApply, callback); ASSERT_EQUALS(MultiApplier::State::kPreStart, multiApplier.getState_forTest()); @@ -147,7 +151,9 @@ TEST_F(MultiApplierTest, MultiApplierInvokesCallbackWithCallbackCanceledStatusUp }; auto callbackResult = getDetectableErrorStatus(); - auto callback = [&](const Status& result) { callbackResult = result; }; + auto callback = [&](const Status& result) { + callbackResult = result; + }; MultiApplier multiApplier(&getExecutor(), operations, multiApply, callback); ASSERT_EQUALS(MultiApplier::State::kPreStart, multiApplier.getState_forTest()); @@ -183,7 +189,9 @@ TEST_F(MultiApplierTest, MultiApplierPassesMultiApplyErrorToCallback) { }; auto callbackResult = getDetectableErrorStatus(); - auto callback = [&](const Status& result) { callbackResult = result; }; + auto callback = [&](const Status& result) { + callbackResult = result; + }; MultiApplier multiApplier(&getExecutor(), operations, multiApply, callback); ASSERT_OK(multiApplier.startup()); @@ -212,7 +220,9 @@ TEST_F(MultiApplierTest, MultiApplierCatchesMultiApplyExceptionAndConvertsToCall }; auto callbackResult = getDetectableErrorStatus(); - auto callback = [&](const Status& result) { callbackResult = result; }; + auto callback = [&](const Status& result) { + callbackResult = result; + }; MultiApplier multiApplier(&getExecutor(), operations, multiApply, callback); ASSERT_OK(multiApplier.startup()); diff --git a/src/mongo/db/repl/oplog_applier.cpp b/src/mongo/db/repl/oplog_applier.cpp index 7462c179a23..af33eaf9633 100644 --- a/src/mongo/db/repl/oplog_applier.cpp +++ b/src/mongo/db/repl/oplog_applier.cpp @@ -63,8 +63,8 @@ OplogBuffer* OplogApplier::getBuffer() const { Future<void> OplogApplier::startup() { auto pf = makePromiseFuture<void>(); - auto callback = - [ this, promise = std::move(pf.promise) ](const CallbackArgs& args) mutable noexcept { + auto callback = [this, + promise = std::move(pf.promise)](const CallbackArgs& args) mutable noexcept { invariant(args.status); LOGV2(21224, "Starting oplog application"); _run(_oplogBuffer); diff --git a/src/mongo/db/repl/oplog_applier_impl.cpp b/src/mongo/db/repl/oplog_applier_impl.cpp index 885d9f923cd..a294d725202 100644 --- a/src/mongo/db/repl/oplog_applier_impl.cpp +++ b/src/mongo/db/repl/oplog_applier_impl.cpp @@ -879,7 +879,9 @@ Status applyOplogEntryOrGroupedInserts(OperationContext* opCtx, // Count each log op application as a separate operation, for reporting purposes - auto incrementOpsAppliedStats = [] { opsAppliedStats.increment(1); }; + auto incrementOpsAppliedStats = [] { + opsAppliedStats.increment(1); + }; auto clockSource = opCtx->getServiceContext()->getFastClockSource(); auto applyStartTime = clockSource->now(); diff --git a/src/mongo/db/repl/oplog_applier_impl_test.cpp b/src/mongo/db/repl/oplog_applier_impl_test.cpp index ed68d116056..3e62bacdb8e 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test.cpp @@ -471,7 +471,9 @@ TEST_F(OplogApplierImplTest, applyOplogEntryToRecordChangeStreamPreImages) { auto op = makeOplogEntry( [opCtx = _opCtx.get()] { WriteUnitOfWork wuow{opCtx}; - ScopeGuard guard{[&wuow] { wuow.commit(); }}; + ScopeGuard guard{[&wuow] { + wuow.commit(); + }}; return repl::getNextOpTime(opCtx); }(), testCase.opType, @@ -688,7 +690,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenant) { // createCollection uses an actual opTime, so we must generate an actually opTime in the future. auto opTime = [opCtx = _opCtx.get()] { WriteUnitOfWork wuow{opCtx}; - ScopeGuard guard{[&wuow] { wuow.commit(); }}; + ScopeGuard guard{[&wuow] { + wuow.commit(); + }}; return repl::getNextOpTime(opCtx); }(); auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {}); @@ -716,7 +720,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenantRequireTenantIDFa // createCollection uses an actual opTime, so we must generate an actually opTime in the future. auto opTime = [opCtx = _opCtx.get()] { WriteUnitOfWork wuow{opCtx}; - ScopeGuard guard{[&wuow] { wuow.commit(); }}; + ScopeGuard guard{[&wuow] { + wuow.commit(); + }}; return repl::getNextOpTime(opCtx); }(); auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {}); @@ -749,7 +755,9 @@ TEST_F(OplogApplierImplTest, RenameCollectionCommandMultitenantAcrossTenantsRequ // createCollection uses an actual opTime, so we must generate an actually opTime in the future. auto opTime = [opCtx = _opCtx.get()] { WriteUnitOfWork wuow{opCtx}; - ScopeGuard guard{[&wuow] { wuow.commit(); }}; + ScopeGuard guard{[&wuow] { + wuow.commit(); + }}; return repl::getNextOpTime(opCtx); }(); auto op = makeCommandOplogEntry(opTime, sourceNss, oRename, {}); diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h index becd58a7aac..f4a7dabd178 100644 --- a/src/mongo/db/repl/oplog_entry.h +++ b/src/mongo/db/repl/oplog_entry.h @@ -48,7 +48,9 @@ std::vector<T> toVector(boost::optional<stdx::variant<T, std::vector<T>>> optVal return {}; } return stdx::visit(OverloadedVisitor{[](T val) { return std::vector<T>{val}; }, - [](const std::vector<T>& vals) { return vals; }}, + [](const std::vector<T>& vals) { + return vals; + }}, *optVals); } } // namespace variant_util diff --git a/src/mongo/db/repl/oplog_fetcher_mock.cpp b/src/mongo/db/repl/oplog_fetcher_mock.cpp index ee51310c925..df951ab76fd 100644 --- a/src/mongo/db/repl/oplog_fetcher_mock.cpp +++ b/src/mongo/db/repl/oplog_fetcher_mock.cpp @@ -44,15 +44,16 @@ OplogFetcherMock::OplogFetcherMock( EnqueueDocumentsFn enqueueDocumentsFn, OnShutdownCallbackFn onShutdownCallbackFn, Config config) - : OplogFetcher(executor, - // Pass a dummy OplogFetcherRestartDecision to the base OplogFetcher. - std::make_unique<OplogFetcherRestartDecisionDefault>(0), - dataReplicatorExternalState, - // Pass a dummy EnqueueDocumentsFn to the base OplogFetcher. - [](const auto& a1, const auto& a2, const auto& a3) { return Status::OK(); }, - // Pass a dummy OnShutdownCallbackFn to the base OplogFetcher. - [](const auto& a, const int b) {}, - config), + : OplogFetcher( + executor, + // Pass a dummy OplogFetcherRestartDecision to the base OplogFetcher. + std::make_unique<OplogFetcherRestartDecisionDefault>(0), + dataReplicatorExternalState, + // Pass a dummy EnqueueDocumentsFn to the base OplogFetcher. + [](const auto& a1, const auto& a2, const auto& a3) { return Status::OK(); }, + // Pass a dummy OnShutdownCallbackFn to the base OplogFetcher. + [](const auto& a, const int b) {}, + config), _oplogFetcherRestartDecision(std::move(oplogFetcherRestartDecision)), _onShutdownCallbackFn(std::move(onShutdownCallbackFn)), _enqueueDocumentsFn(std::move(enqueueDocumentsFn)), diff --git a/src/mongo/db/repl/oplog_fetcher_test.cpp b/src/mongo/db/repl/oplog_fetcher_test.cpp index e05f0db9ff4..154c72b9e34 100644 --- a/src/mongo/db/repl/oplog_fetcher_test.cpp +++ b/src/mongo/db/repl/oplog_fetcher_test.cpp @@ -367,7 +367,9 @@ protected: private: executor::ThreadPoolMock::Options makeThreadPoolMockOptions() const override { executor::ThreadPoolMock::Options options; - options.onCreateThread = []() { Client::initThread("OplogFetcherTest"); }; + options.onCreateThread = []() { + Client::initThread("OplogFetcherTest"); + }; return options; }; }; @@ -594,7 +596,9 @@ TEST_F(OplogFetcherTest, ShuttingExecutorDownShouldPreventOplogFetcherFromStarti TEST_F(OplogFetcherTest, OplogFetcherReturnsOperationFailedIfExecutorFailsToScheduleRunQuery) { TaskExecutorMock taskExecutorMock(&getExecutor()); - taskExecutorMock.shouldFailScheduleWorkRequest = []() { return true; }; + taskExecutorMock.shouldFailScheduleWorkRequest = []() { + return true; + }; // The onShutdownFn should not be called because the oplog fetcher should fail during startup. auto oplogFetcher = makeOplogFetcherWithDifferentExecutor( @@ -617,7 +621,9 @@ TEST_F(OplogFetcherTest, ShuttingExecutorDownAfterStartupButBeforeRunQuerySchedu // Defer scheduling work so that the executor's shutdown happens before startup's work is // scheduled. TaskExecutorMock taskExecutorMock(&getExecutor()); - taskExecutorMock.shouldDeferScheduleWorkRequestByOneSecond = []() { return true; }; + taskExecutorMock.shouldDeferScheduleWorkRequestByOneSecond = []() { + return true; + }; auto oplogFetcher = makeOplogFetcherWithDifferentExecutor(&taskExecutorMock, std::ref(shutdownState)); @@ -640,7 +646,9 @@ TEST_F(OplogFetcherTest, OplogFetcherReturnsCallbackCanceledIfShutdownBeforeRunQ // Defer scheduling work so that the oplog fetcher's shutdown happens before startup's work is // scheduled. TaskExecutorMock taskExecutorMock(&getExecutor()); - taskExecutorMock.shouldDeferScheduleWorkRequestByOneSecond = []() { return true; }; + taskExecutorMock.shouldDeferScheduleWorkRequestByOneSecond = []() { + return true; + }; auto oplogFetcher = makeOplogFetcherWithDifferentExecutor(&taskExecutorMock, std::ref(shutdownState)); diff --git a/src/mongo/db/repl/oplog_test.cpp b/src/mongo/db/repl/oplog_test.cpp index 1b187845291..e2dc0ddb9c3 100644 --- a/src/mongo/db/repl/oplog_test.cpp +++ b/src/mongo/db/repl/oplog_test.cpp @@ -154,7 +154,9 @@ void _testConcurrentLogOp(const F& makeTaskFunction, // Run 2 concurrent logOp() requests using the thread pool. ThreadPool::Options options; options.maxThreads = 2U; - options.onCreateThread = [](const std::string& name) { Client::initThread(name); }; + options.onCreateThread = [](const std::string& name) { + Client::initThread(name); + }; ThreadPool pool(options); pool.startup(); diff --git a/src/mongo/db/repl/replica_set_aware_service.h b/src/mongo/db/repl/replica_set_aware_service.h index bd4871bda0c..6618b7453aa 100644 --- a/src/mongo/db/repl/replica_set_aware_service.h +++ b/src/mongo/db/repl/replica_set_aware_service.h @@ -186,24 +186,24 @@ public: public: explicit Registerer(std::string name, std::vector<std::string> prereqs = {}) - : _registerer(std::move(name), - std::move(prereqs), - [&](ServiceContext* serviceContext) { - if (!_registered) { - _registered = - ActualService::get(serviceContext)->_shouldRegister(); - } - if (*_registered) { - ReplicaSetAwareServiceRegistry::get(serviceContext) - ._registerService(ActualService::get(serviceContext)); - } - }, - [&](ServiceContext* serviceContext) { - if (_registered && *_registered) { - ReplicaSetAwareServiceRegistry::get(serviceContext) - ._unregisterService(ActualService::get(serviceContext)); - } - }) {} + : _registerer( + std::move(name), + std::move(prereqs), + [&](ServiceContext* serviceContext) { + if (!_registered) { + _registered = ActualService::get(serviceContext)->_shouldRegister(); + } + if (*_registered) { + ReplicaSetAwareServiceRegistry::get(serviceContext) + ._registerService(ActualService::get(serviceContext)); + } + }, + [&](ServiceContext* serviceContext) { + if (_registered && *_registered) { + ReplicaSetAwareServiceRegistry::get(serviceContext) + ._unregisterService(ActualService::get(serviceContext)); + } + }) {} private: boost::optional<bool> _registered; diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 9b6e91f4800..2366d8f61d5 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -281,7 +281,9 @@ ReplicationCoordinator::Mode getReplicationModeFromSettings(const ReplSettings& InitialSyncerInterface::Options createInitialSyncerOptions( ReplicationCoordinator* replCoord, ReplicationCoordinatorExternalState* externalState) { InitialSyncerInterface::Options options; - options.getMyLastOptime = [replCoord]() { return replCoord->getMyLastAppliedOpTime(); }; + options.getMyLastOptime = [replCoord]() { + return replCoord->getMyLastAppliedOpTime(); + }; options.setMyLastOptime = [replCoord, externalState](const OpTimeAndWallTime& opTimeAndWallTime) { // Note that setting the last applied opTime forward also advances the global timestamp. @@ -293,7 +295,9 @@ InitialSyncerInterface::Options createInitialSyncerOptions( replCoord->getServiceContext()->getStorageEngine()->setOldestTimestamp( opTimeAndWallTime.opTime.getTimestamp()); }; - options.resetOptimes = [replCoord]() { replCoord->resetMyLastOpTimes(); }; + options.resetOptimes = [replCoord]() { + replCoord->resetMyLastOpTimes(); + }; options.syncSourceSelector = replCoord; options.oplogFetcherMaxFetcherRestarts = externalState->getOplogFetcherInitialSyncMaxFetcherRestarts(); @@ -1128,7 +1132,9 @@ Status ReplicationCoordinatorImpl::waitForMemberState(Interruptible* interruptib } stdx::unique_lock<Latch> lk(_mutex); - auto pred = [this, expectedState]() { return _memberState == expectedState; }; + auto pred = [this, expectedState]() { + return _memberState == expectedState; + }; if (!interruptible->waitForConditionOrInterruptFor(_memberStateChange, lk, timeout, pred)) { return Status(ErrorCodes::ExceededTimeLimit, str::stream() @@ -2478,8 +2484,8 @@ std::shared_ptr<const HelloResponse> ReplicationCoordinatorImpl::awaitHelloRespo return statusWithHello.getValue(); } -StatusWith<OpTime> ReplicationCoordinatorImpl::getLatestWriteOpTime(OperationContext* opCtx) const - noexcept try { +StatusWith<OpTime> ReplicationCoordinatorImpl::getLatestWriteOpTime( + OperationContext* opCtx) const noexcept try { ShouldNotConflictWithSecondaryBatchApplicationBlock noPBWMBlock(opCtx->lockState()); Lock::GlobalLock globalLock(opCtx, MODE_IS); // Check if the node is primary after acquiring global IS lock. diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index da88e94dc46..00b0ff3e60a 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -408,8 +408,8 @@ public: boost::optional<TopologyVersion> clientTopologyVersion, boost::optional<Date_t> deadline) override; - virtual StatusWith<OpTime> getLatestWriteOpTime(OperationContext* opCtx) const - noexcept override; + virtual StatusWith<OpTime> getLatestWriteOpTime( + OperationContext* opCtx) const noexcept override; virtual HostAndPort getCurrentPrimaryHostAndPort() const override; diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp index b556ccd3ca3..6f12c66a56d 100644 --- a/src/mongo/db/repl/replication_coordinator_mock.cpp +++ b/src/mongo/db/repl/replication_coordinator_mock.cpp @@ -781,8 +781,8 @@ std::shared_ptr<const HelloResponse> ReplicationCoordinatorMock::awaitHelloRespo return response; } -StatusWith<OpTime> ReplicationCoordinatorMock::getLatestWriteOpTime(OperationContext* opCtx) const - noexcept { +StatusWith<OpTime> ReplicationCoordinatorMock::getLatestWriteOpTime( + OperationContext* opCtx) const noexcept { return getMyLastAppliedOpTime(); } diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h index 51899a75e5a..2801e2faef1 100644 --- a/src/mongo/db/repl/replication_coordinator_mock.h +++ b/src/mongo/db/repl/replication_coordinator_mock.h @@ -391,8 +391,8 @@ public: const SplitHorizon::Parameters& horizonParams, boost::optional<TopologyVersion> clientTopologyVersion) override; - virtual StatusWith<OpTime> getLatestWriteOpTime(OperationContext* opCtx) const - noexcept override; + virtual StatusWith<OpTime> getLatestWriteOpTime( + OperationContext* opCtx) const noexcept override; virtual HostAndPort getCurrentPrimaryHostAndPort() const override; diff --git a/src/mongo/db/repl/replication_coordinator_noop.cpp b/src/mongo/db/repl/replication_coordinator_noop.cpp index ac7bb2697d5..1896e2ada24 100644 --- a/src/mongo/db/repl/replication_coordinator_noop.cpp +++ b/src/mongo/db/repl/replication_coordinator_noop.cpp @@ -580,8 +580,8 @@ ReplicationCoordinatorNoOp::getHelloResponseFuture( MONGO_UNREACHABLE; } -StatusWith<OpTime> ReplicationCoordinatorNoOp::getLatestWriteOpTime(OperationContext* opCtx) const - noexcept { +StatusWith<OpTime> ReplicationCoordinatorNoOp::getLatestWriteOpTime( + OperationContext* opCtx) const noexcept { return getMyLastAppliedOpTime(); } diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp index 7fae176024f..0242e101991 100644 --- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp +++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp @@ -127,7 +127,9 @@ void ReplCoordTest::init() { _storageInterface->insertDocumentFn = [this](OperationContext* opCtx, const NamespaceStringOrUUID& nsOrUUID, const TimestampedBSONObj& doc, - long long term) { return Status::OK(); }; + long long term) { + return Status::OK(); + }; _storageInterface->createCollFn = [this](OperationContext* opCtx, const NamespaceString& nss, @@ -157,7 +159,9 @@ void ReplCoordTest::init() { auto externalState = std::make_unique<ReplicationCoordinatorExternalStateMock>(); _externalState = externalState.get(); executor::ThreadPoolMock::Options tpOptions; - tpOptions.onCreateThread = []() { Client::initThread("replexec"); }; + tpOptions.onCreateThread = []() { + Client::initThread("replexec"); + }; auto pool = std::make_unique<executor::ThreadPoolMock>(_net, seed, tpOptions); auto replExec = std::make_unique<executor::ThreadPoolTaskExecutor>(std::move(pool), std::move(net)); @@ -340,7 +344,8 @@ void ReplCoordTest::simulateSuccessfulDryRun( } void ReplCoordTest::simulateSuccessfulDryRun() { - auto onDryRunRequest = [](const RemoteCommandRequest& request) {}; + auto onDryRunRequest = [](const RemoteCommandRequest& request) { + }; simulateSuccessfulDryRun(onDryRunRequest); } diff --git a/src/mongo/db/repl/reporter_test.cpp b/src/mongo/db/repl/reporter_test.cpp index 9971f740052..45a6bb84e1c 100644 --- a/src/mongo/db/repl/reporter_test.cpp +++ b/src/mongo/db/repl/reporter_test.cpp @@ -156,12 +156,12 @@ void ReporterTest::setUp() { return updater->prepareReplSetUpdatePositionCommand(); }; - reporter = - std::make_unique<Reporter>(_executorProxy.get(), - [this]() { return prepareReplSetUpdatePositionCommandFn(); }, - HostAndPort("h1"), - Milliseconds(1000), - Milliseconds(5000)); + reporter = std::make_unique<Reporter>( + _executorProxy.get(), + [this]() { return prepareReplSetUpdatePositionCommandFn(); }, + HostAndPort("h1"), + Milliseconds(1000), + Milliseconds(5000)); launchExecutorThread(); if (triggerAtSetUp()) { diff --git a/src/mongo/db/repl/roll_back_local_operations_test.cpp b/src/mongo/db/repl/roll_back_local_operations_test.cpp index 70421f959e1..6c092bdb269 100644 --- a/src/mongo/db/repl/roll_back_local_operations_test.cpp +++ b/src/mongo/db/repl/roll_back_local_operations_test.cpp @@ -347,7 +347,9 @@ private: void checkRemoteIterator(int numNetworkFailures, bool expectedToSucceed) { DBClientConnectionForTest conn(numNetworkFailures); - auto getConnection = [&]() -> DBClientBase* { return &conn; }; + auto getConnection = [&]() -> DBClientBase* { + return &conn; + }; auto localOperation = makeOpAndRecordId(1); OplogInterfaceRemote remoteOplogMock( diff --git a/src/mongo/db/repl/rollback_checker_test.cpp b/src/mongo/db/repl/rollback_checker_test.cpp index 935f6b996d5..1b5adcafb78 100644 --- a/src/mongo/db/repl/rollback_checker_test.cpp +++ b/src/mongo/db/repl/rollback_checker_test.cpp @@ -85,7 +85,8 @@ TEST_F(RollbackCheckerTest, InvalidConstruction) { } TEST_F(RollbackCheckerTest, ShutdownBeforeStart) { - auto callback = [](const RollbackChecker::Result&) {}; + auto callback = [](const RollbackChecker::Result&) { + }; shutdownExecutorThread(); joinExecutorThread(); ASSERT_NOT_OK(getRollbackChecker()->reset(callback).getStatus()); @@ -105,7 +106,8 @@ TEST_F(RollbackCheckerTest, ShutdownBeforeResetSync) { } TEST_F(RollbackCheckerTest, reset) { - auto callback = [](const RollbackChecker::Result&) {}; + auto callback = [](const RollbackChecker::Result&) { + }; auto cbh = unittest::assertGet(getRollbackChecker()->reset(callback)); ASSERT(cbh); diff --git a/src/mongo/db/repl/rollback_impl_test.cpp b/src/mongo/db/repl/rollback_impl_test.cpp index b29c32aab3e..3b7cea56604 100644 --- a/src/mongo/db/repl/rollback_impl_test.cpp +++ b/src/mongo/db/repl/rollback_impl_test.cpp @@ -254,7 +254,9 @@ protected: std::unique_ptr<RollbackImplForTest> _rollback; bool _transitionedToRollback = false; - std::function<void()> _onTransitionToRollbackFn = [this]() { _transitionedToRollback = true; }; + std::function<void()> _onTransitionToRollbackFn = [this]() { + _transitionedToRollback = true; + }; bool _recoveredToStableTimestamp = false; Timestamp _stableTimestamp; @@ -265,10 +267,14 @@ protected: }; bool _recoveredFromOplog = false; - std::function<void()> _onRecoverFromOplogFn = [this]() { _recoveredFromOplog = true; }; + std::function<void()> _onRecoverFromOplogFn = [this]() { + _recoveredFromOplog = true; + }; bool _incrementedRollbackID = false; - std::function<void()> _onRollbackIDIncrementedFn = [this]() { _incrementedRollbackID = true; }; + std::function<void()> _onRollbackIDIncrementedFn = [this]() { + _incrementedRollbackID = true; + }; bool _reconstructedPreparedTransactions = false; std::function<void()> _onPreparedTransactionsReconstructedFn = [this]() { @@ -277,18 +283,25 @@ protected: Timestamp _commonPointFound; std::function<void(Timestamp commonPoint)> _onCommonPointFoundFn = - [this](Timestamp commonPoint) { _commonPointFound = commonPoint; }; + [this](Timestamp commonPoint) { + _commonPointFound = commonPoint; + }; Timestamp _truncatePoint; std::function<void(Timestamp truncatePoint)> _onSetOplogTruncateAfterPointFn = - [this](Timestamp truncatePoint) { _truncatePoint = truncatePoint; }; + [this](Timestamp truncatePoint) { + _truncatePoint = truncatePoint; + }; bool _triggeredOpObserver = false; std::function<void(const OpObserver::RollbackObserverInfo& rbInfo)> _onRollbackOpObserverFn = - [this](const OpObserver::RollbackObserverInfo& rbInfo) { _triggeredOpObserver = true; }; + [this](const OpObserver::RollbackObserverInfo& rbInfo) { + _triggeredOpObserver = true; + }; std::function<void(UUID, NamespaceString)> _onRollbackFileWrittenForNamespaceFn = - [this](UUID, NamespaceString) {}; + [this](UUID, NamespaceString) { + }; std::unique_ptr<Listener> _listener; @@ -848,7 +861,9 @@ DEATH_TEST_F(RollbackImplTest, _storageInterface->setStableTimestamp(nullptr, Timestamp(1, 1)); // Called before aborting prepared transactions. - _onRollbackIDIncrementedFn = [this]() { _incrementedRollbackID = true; }; + _onRollbackIDIncrementedFn = [this]() { + _incrementedRollbackID = true; + }; _onRecoverToStableTimestampFn = [this](Timestamp stableTimestamp) { _recoveredToStableTimestamp = true; @@ -856,7 +871,9 @@ DEATH_TEST_F(RollbackImplTest, }; // Called after reconstructing prepared transactions. We should not be getting here. - _onPreparedTransactionsReconstructedFn = [this]() { ASSERT(false); }; + _onPreparedTransactionsReconstructedFn = [this]() { + ASSERT(false); + }; // We expect to crash when we hit the exception. _rollback->runRollback(_opCtx.get()).ignore(); diff --git a/src/mongo/db/repl/rs_rollback.h b/src/mongo/db/repl/rs_rollback.h index da0ac3bc858..b5bd468091a 100644 --- a/src/mongo/db/repl/rs_rollback.h +++ b/src/mongo/db/repl/rs_rollback.h @@ -145,13 +145,14 @@ class RollbackSource; * 'sleepSecsFn' is an optional testing-only argument for overriding mongo::sleepsecs(). */ -void rollback(OperationContext* opCtx, - const OplogInterface& localOplog, - const RollbackSource& rollbackSource, - int requiredRBID, - ReplicationCoordinator* replCoord, - ReplicationProcess* replicationProcess, - std::function<void(int)> sleepSecsFn = [](int secs) { sleepsecs(secs); }); +void rollback( + OperationContext* opCtx, + const OplogInterface& localOplog, + const RollbackSource& rollbackSource, + int requiredRBID, + ReplicationCoordinator* replCoord, + ReplicationProcess* replicationProcess, + std::function<void(int)> sleepSecsFn = [](int secs) { sleepsecs(secs); }); /** * Initiates the rollback process after transition to ROLLBACK. diff --git a/src/mongo/db/repl/scatter_gather_runner.cpp b/src/mongo/db/repl/scatter_gather_runner.cpp index ace6b8492a2..0cc501dd5e1 100644 --- a/src/mongo/db/repl/scatter_gather_runner.cpp +++ b/src/mongo/db/repl/scatter_gather_runner.cpp @@ -76,7 +76,9 @@ StatusWith<EventHandle> ScatterGatherRunner::start() { // RunnerImpl -> Callback in _callbacks -> RunnerImpl // We must remove callbacks after using them, to break this cycle. std::shared_ptr<RunnerImpl>& impl = _impl; - auto cb = [impl](const RemoteCommandCallbackArgs& cbData) { impl->processResponse(cbData); }; + auto cb = [impl](const RemoteCommandCallbackArgs& cbData) { + impl->processResponse(cbData); + }; return _impl->start(cb); } diff --git a/src/mongo/db/repl/split_prepare_session_manager_test.cpp b/src/mongo/db/repl/split_prepare_session_manager_test.cpp index 91f2f06d45b..571183dd2bc 100644 --- a/src/mongo/db/repl/split_prepare_session_manager_test.cpp +++ b/src/mongo/db/repl/split_prepare_session_manager_test.cpp @@ -78,7 +78,9 @@ TEST_F(SplitPrepareSessionManagerTest, SplitSessionsBasic) { auto sessInfoToSessId = [](const SplitSessionInfo& sessInfo) { return sessInfo.session.getSessionId(); }; - auto sessInfoToReqId = [](const SplitSessionInfo& sessInfo) { return sessInfo.requesterId; }; + auto sessInfoToReqId = [](const SplitSessionInfo& sessInfo) { + return sessInfo.requesterId; + }; std::transform(sessInfos1.begin(), sessInfos1.end(), sessionIds1.begin(), sessInfoToSessId); std::transform(sessInfos2.begin(), sessInfos2.end(), sessionIds2.begin(), sessInfoToSessId); std::transform(sessInfos1.begin(), sessInfos1.end(), returnedIds1.begin(), sessInfoToReqId); diff --git a/src/mongo/db/repl/storage_interface_mock.h b/src/mongo/db/repl/storage_interface_mock.h index 59c470da432..31831f8cbd7 100644 --- a/src/mongo/db/repl/storage_interface_mock.h +++ b/src/mongo/db/repl/storage_interface_mock.h @@ -81,9 +81,15 @@ public: std::function<Status(std::vector<BSONObj>::const_iterator, std::vector<BSONObj>::const_iterator)> insertDocsFn = [](const std::vector<BSONObj>::const_iterator, - const std::vector<BSONObj>::const_iterator) { return Status::OK(); }; - std::function<Status()> abortFn = []() { return Status::OK(); }; - std::function<Status()> commitFn = []() { return Status::OK(); }; + const std::vector<BSONObj>::const_iterator) { + return Status::OK(); + }; + std::function<Status()> abortFn = []() { + return Status::OK(); + }; + std::function<Status()> commitFn = []() { + return Status::OK(); + }; }; class StorageInterfaceMock : public StorageInterface { diff --git a/src/mongo/db/repl/storage_timestamp_test.cpp b/src/mongo/db/repl/storage_timestamp_test.cpp index 768f6e23616..1f0cfb1dcce 100644 --- a/src/mongo/db/repl/storage_timestamp_test.cpp +++ b/src/mongo/db/repl/storage_timestamp_test.cpp @@ -400,14 +400,14 @@ public: { WriteUnitOfWork wuow(_opCtx); // Timestamping index completion. Primaries write an oplog entry. - ASSERT_OK( - indexer.commit(_opCtx, - coll.getWritableCollection(_opCtx), - [&](const BSONObj& indexSpec) { - _opCtx->getServiceContext()->getOpObserver()->onCreateIndex( - _opCtx, coll->ns(), coll->uuid(), indexSpec, false); - }, - MultiIndexBlock::kNoopOnCommitFn)); + ASSERT_OK(indexer.commit( + _opCtx, + coll.getWritableCollection(_opCtx), + [&](const BSONObj& indexSpec) { + _opCtx->getServiceContext()->getOpObserver()->onCreateIndex( + _opCtx, coll->ns(), coll->uuid(), indexSpec, false); + }, + MultiIndexBlock::kNoopOnCommitFn)); // The timestamping repsponsibility is placed on the caller rather than the // MultiIndexBlock. wuow.commit(); @@ -1976,22 +1976,22 @@ public: // All callers of `MultiIndexBlock::commit` are responsible for timestamping index // completion Primaries write an oplog entry. Secondaries explicitly set a // timestamp. - ASSERT_OK( - indexer.commit(_opCtx, - autoColl.getWritableCollection(_opCtx), - [&](const BSONObj& indexSpec) { - if (simulatePrimary) { - // The timestamping responsibility for each index is placed - // on the caller. - _opCtx->getServiceContext()->getOpObserver()->onCreateIndex( - _opCtx, nss, coll->uuid(), indexSpec, false); - } else { - const auto currentTime = _clock->getTime(); - ASSERT_OK(_opCtx->recoveryUnit()->setTimestamp( - currentTime.clusterTime().asTimestamp())); - } - }, - MultiIndexBlock::kNoopOnCommitFn)); + ASSERT_OK(indexer.commit( + _opCtx, + autoColl.getWritableCollection(_opCtx), + [&](const BSONObj& indexSpec) { + if (simulatePrimary) { + // The timestamping responsibility for each index is placed + // on the caller. + _opCtx->getServiceContext()->getOpObserver()->onCreateIndex( + _opCtx, nss, coll->uuid(), indexSpec, false); + } else { + const auto currentTime = _clock->getTime(); + ASSERT_OK(_opCtx->recoveryUnit()->setTimestamp( + currentTime.clusterTime().asTimestamp())); + } + }, + MultiIndexBlock::kNoopOnCommitFn)); wuow.commit(); } abortOnExit.dismiss(); @@ -2733,14 +2733,14 @@ TEST_F(StorageTimestampTest, IndexBuildsResolveErrorsDuringStateChangeToPrimary) { WriteUnitOfWork wuow(_opCtx); - ASSERT_OK( - indexer.commit(_opCtx, - collection.getWritableCollection(_opCtx), - [&](const BSONObj& indexSpec) { - _opCtx->getServiceContext()->getOpObserver()->onCreateIndex( - _opCtx, collection->ns(), collection->uuid(), indexSpec, false); - }, - MultiIndexBlock::kNoopOnCommitFn)); + ASSERT_OK(indexer.commit( + _opCtx, + collection.getWritableCollection(_opCtx), + [&](const BSONObj& indexSpec) { + _opCtx->getServiceContext()->getOpObserver()->onCreateIndex( + _opCtx, collection->ns(), collection->uuid(), indexSpec, false); + }, + MultiIndexBlock::kNoopOnCommitFn)); wuow.commit(); } abortOnExit.dismiss(); diff --git a/src/mongo/db/repl/sync_source_resolver_test.cpp b/src/mongo/db/repl/sync_source_resolver_test.cpp index 45b0a05a1ea..b1eec4d4feb 100644 --- a/src/mongo/db/repl/sync_source_resolver_test.cpp +++ b/src/mongo/db/repl/sync_source_resolver_test.cpp @@ -93,14 +93,18 @@ const OpTime lastOpTimeFetched(Timestamp(Seconds(100), 1U), 1LL); void SyncSourceResolverTest::setUp() { executor::ThreadPoolExecutorTest::setUp(); - _shouldFailRequest = [](const executor::RemoteCommandRequest&) { return false; }; + _shouldFailRequest = [](const executor::RemoteCommandRequest&) { + return false; + }; _executorProxy = std::make_unique<TaskExecutorWithFailureInScheduleRemoteCommand>( &getExecutor(), [this](const executor::RemoteCommandRequest& request) { return _shouldFailRequest(request); }); _response.syncSourceStatus = getDetectableErrorStatus(); - _onCompletion = [this](const SyncSourceResolverResponse& response) { _response = response; }; + _onCompletion = [this](const SyncSourceResolverResponse& response) { + _response = response; + }; _selector = std::make_unique<SyncSourceSelectorMock>(); _resolver = _makeResolver(lastOpTimeFetched, OpTime()); @@ -167,7 +171,8 @@ TEST_F(SyncSourceResolverTest, InvalidConstruction) { SyncSourceSelectorMock selector; const OpTime lastOpTimeFetched(Timestamp(Seconds(100), 1U), 1LL); const OpTime requiredOpTime; - auto onCompletion = [](const SyncSourceResolverResponse&) {}; + auto onCompletion = [](const SyncSourceResolverResponse&) { + }; // Null task executor. ASSERT_THROWS_CODE_AND_WHAT( @@ -279,7 +284,9 @@ TEST_F(SyncSourceResolverTest, TEST_F(SyncSourceResolverTest, SyncSourceResolverReturnsScheduleErrorIfTaskExecutorFailsToScheduleRemoteCommand) { - _shouldFailRequest = [](const executor::RemoteCommandRequest&) { return true; }; + _shouldFailRequest = [](const executor::RemoteCommandRequest&) { + return true; + }; ASSERT_EQUALS(ErrorCodes::OperationFailed, _resolver->startup()); ASSERT_EQUALS(ErrorCodes::OperationFailed, _response.syncSourceStatus); } diff --git a/src/mongo/db/repl/sync_source_selector_mock.h b/src/mongo/db/repl/sync_source_selector_mock.h index 8253831dd59..f8d2a86456b 100644 --- a/src/mongo/db/repl/sync_source_selector_mock.h +++ b/src/mongo/db/repl/sync_source_selector_mock.h @@ -95,7 +95,8 @@ private: OpTime _chooseNewSyncSourceOpTime; // This is run every time chooseNewSyncSource() is called. - ChooseNewSyncSourceHook _chooseNewSyncSourceHook = []() {}; + ChooseNewSyncSourceHook _chooseNewSyncSourceHook = []() { + }; // This is the most recently denylisted sync source passed to denylistSyncSource(). HostAndPort _lastDenylistedSyncSource; diff --git a/src/mongo/db/repl/task_executor_mock.h b/src/mongo/db/repl/task_executor_mock.h index 6f4ec02546c..a8b101f8f99 100644 --- a/src/mongo/db/repl/task_executor_mock.h +++ b/src/mongo/db/repl/task_executor_mock.h @@ -59,10 +59,14 @@ public: bool hasTasks() override; // Override to make scheduleWork() fail during testing. - ShouldFailScheduleWorkRequestFn shouldFailScheduleWorkRequest = []() { return false; }; + ShouldFailScheduleWorkRequestFn shouldFailScheduleWorkRequest = []() { + return false; + }; // Override to make scheduleWorkAt() fail during testing. - ShouldFailScheduleWorkRequestFn shouldFailScheduleWorkAtRequest = []() { return false; }; + ShouldFailScheduleWorkRequestFn shouldFailScheduleWorkAtRequest = []() { + return false; + }; // If the predicate returns true, scheduleWork() will schedule the task 1 second later instead // of running immediately. This allows us to test cancellation handling in callbacks scheduled @@ -73,7 +77,9 @@ public: // Override to make scheduleRemoteCommand fail during testing. ShouldFailScheduleRemoteCommandRequestFn shouldFailScheduleRemoteCommandRequest = - [](const executor::RemoteCommandRequestOnAny&) { return false; }; + [](const executor::RemoteCommandRequestOnAny&) { + return false; + }; }; } // namespace repl diff --git a/src/mongo/db/repl/task_runner.cpp b/src/mongo/db/repl/task_runner.cpp index 418505bbbdc..a109c7cbd64 100644 --- a/src/mongo/db/repl/task_runner.cpp +++ b/src/mongo/db/repl/task_runner.cpp @@ -79,7 +79,9 @@ TaskRunner::NextAction runSingleTask(const TaskRunner::Task& task, // static TaskRunner::Task TaskRunner::makeCancelTask() { - return [](OperationContext* opCtx, const Status& status) { return NextAction::kCancel; }; + return [](OperationContext* opCtx, const Status& status) { + return NextAction::kCancel; + }; } TaskRunner::TaskRunner(ThreadPool* threadPool) diff --git a/src/mongo/db/repl/task_runner_test.cpp b/src/mongo/db/repl/task_runner_test.cpp index d71dc3c42e8..089a76381f1 100644 --- a/src/mongo/db/repl/task_runner_test.cpp +++ b/src/mongo/db/repl/task_runner_test.cpp @@ -120,7 +120,9 @@ OpIdVector _testRunTaskTwice(TaskRunnerTest& test, std::vector<unsigned int> _testRunTaskTwice(TaskRunnerTest& test, TaskRunner::NextAction nextAction) { - auto schedule = [&](Task task) { test.getTaskRunner().schedule(std::move(task)); }; + auto schedule = [&](Task task) { + test.getTaskRunner().schedule(std::move(task)); + }; return _testRunTaskTwice(test, nextAction, schedule); } diff --git a/src/mongo/db/repl/task_runner_test_fixture.cpp b/src/mongo/db/repl/task_runner_test_fixture.cpp index 760033adaee..f7d1f85f182 100644 --- a/src/mongo/db/repl/task_runner_test_fixture.cpp +++ b/src/mongo/db/repl/task_runner_test_fixture.cpp @@ -63,7 +63,9 @@ void TaskRunnerTest::destroyTaskRunner() { void TaskRunnerTest::setUp() { ThreadPool::Options options; options.poolName = "TaskRunnerTest"; - options.onCreateThread = [](const std::string& name) { Client::initThread(name); }; + options.onCreateThread = [](const std::string& name) { + Client::initThread(name); + }; _threadPool = std::make_unique<ThreadPool>(options); _threadPool->startup(); diff --git a/src/mongo/db/repl/tenant_file_cloner.cpp b/src/mongo/db/repl/tenant_file_cloner.cpp index b909039eed1..77f37865d46 100644 --- a/src/mongo/db/repl/tenant_file_cloner.cpp +++ b/src/mongo/db/repl/tenant_file_cloner.cpp @@ -72,9 +72,9 @@ TenantFileCloner::TenantFileCloner(const UUID& backupId, _queryStage("query", this, &TenantFileCloner::queryStage), _fsWorkTaskRunner(dbPool), _scheduleFsWorkFn([this](executor::TaskExecutor::CallbackFn work) { - auto task = [ this, work = std::move(work) ]( - OperationContext * opCtx, - const Status& status) mutable noexcept->TaskRunner::NextAction { + auto task = [this, work = std::move(work)]( + OperationContext* opCtx, + const Status& status) mutable noexcept -> TaskRunner::NextAction { try { work(executor::TaskExecutor::CallbackArgs(nullptr, {}, status, opCtx)); } catch (const DBException& e) { diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp index 900a2707225..82cacd6c499 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp @@ -1026,17 +1026,15 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::_openBackupCursor( auto fetchStatus = std::make_shared<boost::optional<Status>>(); auto uniqueMetadataInfo = std::make_unique<boost::optional<shard_merge_utils::MetadataInfo>>(); - const auto fetcherCallback = - [ - this, - self = shared_from_this(), - fetchStatus, - metadataInfoPtr = uniqueMetadataInfo.get(), - token, - startMigrationDonorTimestamp - ](const Fetcher::QueryResponseStatus& dataStatus, - Fetcher::NextAction* nextAction, - BSONObjBuilder* getMoreBob) noexcept { + const auto fetcherCallback = [this, + self = shared_from_this(), + fetchStatus, + metadataInfoPtr = uniqueMetadataInfo.get(), + token, + startMigrationDonorTimestamp]( + const Fetcher::QueryResponseStatus& dataStatus, + Fetcher::NextAction* nextAction, + BSONObjBuilder* getMoreBob) noexcept { try { uassertStatusOK(dataStatus); uassert(ErrorCodes::CallbackCanceled, "backup cursor interrupted", !token.isCanceled()); diff --git a/src/mongo/db/repl/tenant_migration_recipient_service_shard_merge_test.cpp b/src/mongo/db/repl/tenant_migration_recipient_service_shard_merge_test.cpp index 4ff527d62c9..64c76139b63 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service_shard_merge_test.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service_shard_merge_test.cpp @@ -223,7 +223,9 @@ public: _net = net.get(); executor::ThreadPoolMock::Options dbThreadPoolOptions; - dbThreadPoolOptions.onCreateThread = []() { Client::initThread("FetchMockTaskExecutor"); }; + dbThreadPoolOptions.onCreateThread = []() { + Client::initThread("FetchMockTaskExecutor"); + }; auto pool = std::make_unique<executor::ThreadPoolMock>(_net, 1, dbThreadPoolOptions); _threadpoolTaskExecutor = diff --git a/src/mongo/db/repl/tenant_oplog_applier.cpp b/src/mongo/db/repl/tenant_oplog_applier.cpp index feef4bcfc05..ea93bbacc7d 100644 --- a/src/mongo/db/repl/tenant_oplog_applier.cpp +++ b/src/mongo/db/repl/tenant_oplog_applier.cpp @@ -1064,7 +1064,8 @@ Status TenantOplogApplier::_applyOplogEntryOrGroupedInserts( } } // We don't count tenant application in the ops applied stats. - auto incrementOpsAppliedStats = [] {}; + auto incrementOpsAppliedStats = [] { + }; auto status = OplogApplierUtils::applyOplogEntryOrGroupedInsertsCommon(opCtx, entryOrGroupedInserts, oplogApplicationMode, diff --git a/src/mongo/db/repl/tenant_oplog_applier_test.cpp b/src/mongo/db/repl/tenant_oplog_applier_test.cpp index cb1cef8c6cd..7e2b2bc2862 100644 --- a/src/mongo/db/repl/tenant_oplog_applier_test.cpp +++ b/src/mongo/db/repl/tenant_oplog_applier_test.cpp @@ -140,7 +140,9 @@ public: auto network = std::make_unique<executor::NetworkInterfaceMock>(); _net = network.get(); executor::ThreadPoolMock::Options thread_pool_options; - thread_pool_options.onCreateThread = [] { Client::initThread("TenantOplogApplier"); }; + thread_pool_options.onCreateThread = [] { + Client::initThread("TenantOplogApplier"); + }; _executor = makeSharedThreadPoolTestExecutor(std::move(network), thread_pool_options); _executor->startup(); _oplogBuffer.startup(nullptr); @@ -464,9 +466,10 @@ TEST_F(TenantOplogApplierTest, ApplyInsert_DatabaseMissing) { NamespaceString::createNamespaceString_forTest(_dbName.toStringWithTenantId(), "bar"), UUID::gen()); bool onInsertsCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString&, - const std::vector<BSONObj>&) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString&, const std::vector<BSONObj>&) { + onInsertsCalled = true; + }; pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -495,9 +498,10 @@ TEST_F(TenantOplogApplierTest, ApplyInsert_CollectionMissing) { NamespaceString::createNamespaceString_forTest(_dbName.toStringWithTenantId(), "bar"), UUID::gen()); bool onInsertsCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString&, - const std::vector<BSONObj>&) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString&, const std::vector<BSONObj>&) { + onInsertsCalled = true; + }; pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -531,9 +535,10 @@ TEST_F(TenantOplogApplierTest, ApplyInsert_InsertExisting) { auto entry = makeInsertOplogEntry(1, nss, uuid); bool onInsertsCalled = false; bool onUpdateCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString&, - const std::vector<BSONObj>&) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString&, const std::vector<BSONObj>&) { + onInsertsCalled = true; + }; _opObserver->onUpdateFn = [&](OperationContext* opCtx, const OplogUpdateEntryArgs&) { onUpdateCalled = true; }; @@ -576,9 +581,10 @@ TEST_F(TenantOplogApplierTest, ApplyInsert_UniqueKey_InsertExisting) { auto entry = makeOplogEntry(repl::OpTypeEnum::kInsert, nss, uuid, BSON("_id" << 1 << "data" << 2)); bool onInsertsCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString&, - const std::vector<BSONObj>&) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString&, const std::vector<BSONObj>&) { + onInsertsCalled = true; + }; pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -713,9 +719,10 @@ TEST_F(TenantOplogApplierTest, ApplyUpdate_MissingDocument) { BSON("_id" << 0)); bool onInsertsCalled = false; bool onUpdateCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString& nss, - const std::vector<BSONObj>& docs) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString& nss, const std::vector<BSONObj>& docs) { + onInsertsCalled = true; + }; _opObserver->onUpdateFn = [&](OperationContext* opCtx, const OplogUpdateEntryArgs&) { onUpdateCalled = true; }; @@ -928,7 +935,9 @@ TEST_F(TenantOplogApplierTest, ApplyCreateCollCommand_CollExisting) { const CollectionPtr&, const NamespaceString& collNss, const CollectionOptions&, - const BSONObj&) { applyCmdCalled = true; }; + const BSONObj&) { + applyCmdCalled = true; + }; auto entry = OplogEntry(op); pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -970,7 +979,9 @@ TEST_F(TenantOplogApplierTest, ApplyRenameCollCommand_CollExisting) { const boost::optional<UUID>& uuid, const boost::optional<UUID>& dropTargetUUID, std::uint64_t numRecords, - bool stayTemp) { applyCmdCalled = true; }; + bool stayTemp) { + applyCmdCalled = true; + }; auto entry = OplogEntry(op); pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -1126,7 +1137,9 @@ TEST_F(TenantOplogApplierTest, ApplyCreateCollCommand_WrongNSS) { const CollectionPtr&, const NamespaceString& collNss, const CollectionOptions&, - const BSONObj&) { applyCmdCalled = true; }; + const BSONObj&) { + applyCmdCalled = true; + }; auto entry = OplogEntry(op); pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -1161,7 +1174,9 @@ TEST_F(TenantOplogApplierTest, ApplyCreateCollCommand_WrongNSS_Merge) { const CollectionPtr&, const NamespaceString& collNss, const CollectionOptions&, - const BSONObj&) { applyCmdCalled = true; }; + const BSONObj&) { + applyCmdCalled = true; + }; auto entry = OplogEntry(op); pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -1197,7 +1212,9 @@ TEST_F(TenantOplogApplierTest, ApplyDropIndexesCommand_IndexNotFound) { const NamespaceString& nss, const boost::optional<UUID>& uuid, const std::string& indexName, - const BSONObj& idxDescriptor) { applyCmdCalled = true; }; + const BSONObj& idxDescriptor) { + applyCmdCalled = true; + }; auto entry = OplogEntry(op); pushOps({entry}); @@ -1316,9 +1333,10 @@ TEST_F(TenantOplogApplierTest, ApplyCRUD_WrongNSS) { auto uuid = createCollectionWithUuid(_opCtx.get(), nss); auto entry = makeInsertOplogEntry(1, nss, uuid); bool onInsertsCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString& nss, - const std::vector<BSONObj>& docs) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString& nss, const std::vector<BSONObj>& docs) { + onInsertsCalled = true; + }; pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -1348,9 +1366,10 @@ TEST_F(TenantOplogApplierTest, ApplyCRUD_WrongNSS_Merge) { auto uuid = createCollectionWithUuid(_opCtx.get(), nss); auto entry = makeInsertOplogEntry(1, nss, uuid); bool onInsertsCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString& nss, - const std::vector<BSONObj>& docs) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString& nss, const std::vector<BSONObj>& docs) { + onInsertsCalled = true; + }; pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); @@ -1378,9 +1397,10 @@ TEST_F(TenantOplogApplierTest, ApplyCRUD_WrongUUID) { auto uuid = createCollectionWithUuid(_opCtx.get(), nss); auto entry = makeInsertOplogEntry(1, nss_to_apply, uuid); bool onInsertsCalled = false; - _opObserver->onInsertsFn = [&](OperationContext* opCtx, - const NamespaceString& nss, - const std::vector<BSONObj>& docs) { onInsertsCalled = true; }; + _opObserver->onInsertsFn = + [&](OperationContext* opCtx, const NamespaceString& nss, const std::vector<BSONObj>& docs) { + onInsertsCalled = true; + }; pushOps({entry}); auto writerPool = makeTenantMigrationWriterPool(); diff --git a/src/mongo/db/repl/tenant_oplog_batcher_test.cpp b/src/mongo/db/repl/tenant_oplog_batcher_test.cpp index 4ba7173aba3..273e1a9f52c 100644 --- a/src/mongo/db/repl/tenant_oplog_batcher_test.cpp +++ b/src/mongo/db/repl/tenant_oplog_batcher_test.cpp @@ -55,7 +55,9 @@ public: auto network = std::make_unique<executor::NetworkInterfaceMock>(); _net = network.get(); executor::ThreadPoolMock::Options thread_pool_options; - thread_pool_options.onCreateThread = [] { Client::initThread("TenantOplogBatcher"); }; + thread_pool_options.onCreateThread = [] { + Client::initThread("TenantOplogBatcher"); + }; _executor = makeSharedThreadPoolTestExecutor(std::move(network), thread_pool_options); _executor->startup(); _oplogBuffer.startup(nullptr); |
