diff options
author | Tommaso Tocci <tommaso.tocci@mongodb.com> | 2022-06-17 00:42:45 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-17 01:41:35 +0000 |
commit | 83f13bb6335a153b2475bbe9456cec058483cf6e (patch) | |
tree | 1d20395cd515d7603d87781621bbb75c4731f91a /src/mongo/db/s/collmod_coordinator.cpp | |
parent | 5daedbb66eec88dd2e5beb41d22b8b13cafb841d (diff) | |
download | mongo-83f13bb6335a153b2475bbe9456cec058483cf6e.tar.gz |
SERVER-66932 Unify recoverable DDL coordinators code
Diffstat (limited to 'src/mongo/db/s/collmod_coordinator.cpp')
-rw-r--r-- | src/mongo/db/s/collmod_coordinator.cpp | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/mongo/db/s/collmod_coordinator.cpp b/src/mongo/db/s/collmod_coordinator.cpp index ebf179c21c8..ecd23800b69 100644 --- a/src/mongo/db/s/collmod_coordinator.cpp +++ b/src/mongo/db/s/collmod_coordinator.cpp @@ -77,10 +77,7 @@ bool hasTimeSeriesGranularityUpdate(const CollModRequest& request) { CollModCoordinator::CollModCoordinator(ShardingDDLCoordinatorService* service, const BSONObj& initialState) - : ShardingDDLCoordinator(service, initialState), - _initialState{initialState.getOwned()}, - _doc{CollModCoordinatorDocument::parse(IDLParserErrorContext("CollModCoordinatorDocument"), - _initialState)}, + : RecoverableShardingDDLCoordinator(service, initialState), _request{_doc.getCollModRequest()} {} void CollModCoordinator::checkIfOptionsConflict(const BSONObj& doc) const { @@ -122,29 +119,6 @@ boost::optional<BSONObj> CollModCoordinator::reportForCurrentOp( return bob.obj(); } -void CollModCoordinator::_enterPhase(Phase newPhase) { - StateDoc newDoc(_doc); - newDoc.setPhase(newPhase); - - LOGV2_DEBUG(6069401, - 2, - "CollMod coordinator phase transition", - "namespace"_attr = nss(), - "newPhase"_attr = CollModCoordinatorPhase_serializer(newDoc.getPhase()), - "oldPhase"_attr = CollModCoordinatorPhase_serializer(_doc.getPhase())); - - if (_doc.getPhase() == Phase::kUnset) { - newDoc = _insertStateDocument(std::move(newDoc)); - } else { - newDoc = _updateStateDocument(cc().makeOperationContext().get(), std::move(newDoc)); - } - - { - stdx::unique_lock ul{_docMutex}; - _doc = std::move(newDoc); - } -} - void CollModCoordinator::_performNoopRetryableWriteOnParticipants( OperationContext* opCtx, const std::shared_ptr<executor::TaskExecutor>& executor) { auto shardsAndConfigsvr = [&] { @@ -154,9 +128,9 @@ void CollModCoordinator::_performNoopRetryableWriteOnParticipants( return participants; }(); - _doc = _updateSession(opCtx, _doc); + _updateSession(opCtx); sharding_ddl_util::performNoopRetryableWriteOnShards( - opCtx, shardsAndConfigsvr, getCurrentSession(_doc), executor); + opCtx, shardsAndConfigsvr, getCurrentSession(), executor); } void CollModCoordinator::_saveCollectionInfoOnCoordinatorIfNecessary(OperationContext* opCtx) { @@ -229,7 +203,7 @@ ExecutorFuture<void> CollModCoordinator::_runImpl( auto* opCtx = opCtxHolder.get(); getForwardableOpMetadata().setOn(opCtx); - _doc = _updateSession(opCtx, _doc); + _updateSession(opCtx); _saveCollectionInfoOnCoordinatorIfNecessary(opCtx); @@ -258,7 +232,7 @@ ExecutorFuture<void> CollModCoordinator::_runImpl( auto* opCtx = opCtxHolder.get(); getForwardableOpMetadata().setOn(opCtx); - _doc = _updateSession(opCtx, _doc); + _updateSession(opCtx); _saveCollectionInfoOnCoordinatorIfNecessary(opCtx); _saveShardingInfoOnCoordinatorIfNecessary(opCtx); @@ -285,7 +259,7 @@ ExecutorFuture<void> CollModCoordinator::_runImpl( auto* opCtx = opCtxHolder.get(); getForwardableOpMetadata().setOn(opCtx); - _doc = _updateSession(opCtx, _doc); + _updateSession(opCtx); _saveCollectionInfoOnCoordinatorIfNecessary(opCtx); _saveShardingInfoOnCoordinatorIfNecessary(opCtx); |