mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-50022 Implement fetchTimestamp digestion on recipient shards
This commit is contained in:
parent
1e43514cb2
commit
fe965f698b
@ -95,8 +95,10 @@ ExecutorFuture<void> RecipientStateMachine::_awaitAllDonorsPreparedToDonateThenT
|
||||
return ExecutorFuture<void>(**executor, Status::OK());
|
||||
}
|
||||
|
||||
return _allDonorsPreparedToDonate.getFuture().thenRunOn(**executor).then([this]() {
|
||||
_transitionState(RecipientStateEnum::kCloning);
|
||||
return _allDonorsPreparedToDonate.getFuture()
|
||||
.thenRunOn(**executor)
|
||||
.then([this](Timestamp fetchTimestamp) {
|
||||
_transitionState(RecipientStateEnum::kCloning, fetchTimestamp);
|
||||
});
|
||||
}
|
||||
|
||||
@ -147,9 +149,24 @@ void RecipientStateMachine::_renameTemporaryReshardingCollectionThenDeleteLocalS
|
||||
_transitionState(RecipientStateEnum::kDone);
|
||||
}
|
||||
|
||||
void RecipientStateMachine::_transitionState(RecipientStateEnum endState) {
|
||||
void RecipientStateMachine::_fulfillAllDonorsPreparedToDonate(Timestamp fetchTimestamp) {
|
||||
_allDonorsPreparedToDonate.emplaceValue(fetchTimestamp);
|
||||
}
|
||||
|
||||
void RecipientStateMachine::_transitionState(RecipientStateEnum endState,
|
||||
boost::optional<Timestamp> fetchTimestamp) {
|
||||
ReshardingRecipientDocument replacementDoc(_recipientDoc);
|
||||
replacementDoc.setState(endState);
|
||||
if (fetchTimestamp) {
|
||||
auto& fetchTimestampStruct = replacementDoc.getFetchTimestampStruct();
|
||||
|
||||
// If the recipient is recovering and already knows the fetchTimestamp, it cannot change
|
||||
if (fetchTimestampStruct.getFetchTimestamp())
|
||||
invariant(fetchTimestampStruct.getFetchTimestamp().get() == fetchTimestamp.get());
|
||||
|
||||
fetchTimestampStruct.setFetchTimestamp(std::move(fetchTimestamp));
|
||||
}
|
||||
|
||||
_updateRecipientDocument(std::move(replacementDoc));
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,11 @@ private:
|
||||
|
||||
void _renameTemporaryReshardingCollectionThenDeleteLocalState();
|
||||
|
||||
void _fulfillAllDonorsPreparedToDonate(Timestamp);
|
||||
|
||||
// Transitions the state on-disk and in-memory to 'endState'.
|
||||
void _transitionState(RecipientStateEnum endState);
|
||||
void _transitionState(RecipientStateEnum endState,
|
||||
boost::optional<Timestamp> fetchTimestamp = boost::none);
|
||||
|
||||
// Transitions the state on-disk and in-memory to kError.
|
||||
void _transitionStateToError(const Status& status);
|
||||
@ -118,7 +121,7 @@ private:
|
||||
|
||||
// Each promise below corresponds to a state on the recipient state machine. They are listed in
|
||||
// ascending order, such that the first promise below will be the first promise fulfilled.
|
||||
SharedPromise<void> _allDonorsPreparedToDonate;
|
||||
SharedPromise<Timestamp> _allDonorsPreparedToDonate;
|
||||
|
||||
SharedPromise<void> _allDonorsMirroring;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user