0
0
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:
jannaerin 2020-09-23 16:14:02 +00:00 committed by Evergreen Agent
parent 1e43514cb2
commit fe965f698b
2 changed files with 26 additions and 6 deletions

View File

@ -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));
}

View File

@ -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;