diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2021-03-08 22:37:40 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-09 00:03:51 +0000 |
commit | db2e46857ce1c2bf90fda9842287cc5940fce81c (patch) | |
tree | 28d1ddbd9376da377ff37cdc466a51b9550d577e /src/mongo/db/s/resharding/resharding_recipient_service.h | |
parent | 421ddfa11b6eb4b38f676a0c4da3560fcf63713d (diff) | |
download | mongo-db2e46857ce1c2bf90fda9842287cc5940fce81c.tar.gz |
SERVER-54980 Split donor and recipent documents into im/mutable state.
Removes the unused strictConsistencyTimestamp field from the recipient
document.
Also explicitly sets strict:true and strict:false for all of
resharding's IDL types.
Diffstat (limited to 'src/mongo/db/s/resharding/resharding_recipient_service.h')
-rw-r--r-- | src/mongo/db/s/resharding/resharding_recipient_service.h | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/mongo/db/s/resharding/resharding_recipient_service.h b/src/mongo/db/s/resharding/resharding_recipient_service.h index 59e41df7b63..a5fab606b8b 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service.h +++ b/src/mongo/db/s/resharding/resharding_recipient_service.h @@ -133,6 +133,8 @@ public: const ReshardingRecipientDocument& recipientDoc); private: + RecipientStateMachine(const ReshardingRecipientDocument& recipientDoc); + // The following functions correspond to the actions to take at a particular recipient state. ExecutorFuture<void> _awaitAllDonorsPreparedToDonateThenTransitionToCreatingCollection( const std::shared_ptr<executor::ScopedTaskExecutor>& executor); @@ -153,17 +155,26 @@ private: void _renameTemporaryReshardingCollection(); - // Transitions the state on-disk and in-memory to 'endState'. - void _transitionState(RecipientStateEnum endState, - boost::optional<Timestamp> fetchTimestamp = boost::none, - boost::optional<Status> abortReason = boost::none); + // Transitions the on-disk and in-memory state to 'newState'. + void _transitionState(RecipientStateEnum newState); + + void _transitionState(RecipientShardContext&& newRecipientCtx, + boost::optional<Timestamp>&& fetchTimestamp); + + // Transitions the on-disk and in-memory state to RecipientStateEnum::kCreatingCollection. + void _transitionToCreatingCollection(Timestamp fetchTimestamp); + + // Transitions the on-disk and in-memory state to RecipientStateEnum::kError. + void _transitionToError(Status abortReason); void _updateCoordinator(); - // Updates the recipient document on-disk and in-memory with the 'replacementDoc.' - void _updateRecipientDocument(ReshardingRecipientDocument&& replacementDoc); + // Updates the mutable portion of the on-disk and in-memory recipient document with + // 'newRecipientCtx' and 'fetchTimestamp'. + void _updateRecipientDocument(RecipientShardContext&& newRecipientCtx, + boost::optional<Timestamp>&& fetchTimestamp); - // Removes the local recipient document from disk and clears the in-memory state. + // Removes the local recipient document from disk. void _removeRecipientDocument(); // Removes any docs from the oplog applier progress and txn applier progress collections that @@ -180,12 +191,15 @@ private: // (abort resharding). void _onAbortOrStepdown(WithLock, Status status); - // The in-memory representation of the underlying document in + // The in-memory representation of the immutable portion of the document in // config.localReshardingOperations.recipient. - ReshardingRecipientDocument _recipientDoc; + const CommonReshardingMetadata _metadata; + const std::vector<ShardId> _donorShardIds; - // The id both for the resharding operation and for the primary-only-service instance. - const UUID _id; + // The in-memory representation of the mutable portion of the document in + // config.localReshardingOperations.recipient. + RecipientShardContext _recipientCtx; + boost::optional<Timestamp> _fetchTimestamp; std::unique_ptr<ReshardingCollectionCloner> _collectionCloner; std::vector<std::unique_ptr<ReshardingTxnCloner>> _txnCloners; @@ -200,7 +214,7 @@ private: std::vector<ExecutorFuture<void>> _oplogFetcherFutures; // Protects the promises below - Mutex _mutex = MONGO_MAKE_LATCH("ReshardingRecipient::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH("RecipientStateMachine::_mutex"); boost::optional<ReshardingCriticalSection> _critSec; |