diff options
author | Matthew Russotto <matthew.russotto@mongodb.com> | 2021-02-04 13:36:07 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-05 00:40:47 +0000 |
commit | 485d115ac7d0c7cb50e792d7aeeff41fbe621c89 (patch) | |
tree | d2d92c22bf25a0ddbd479fb8741d118ca5cf6c64 /src/mongo/db/repl_index_build_state.h | |
parent | b7a167b7a683cc5620c56e915530458a680557b2 (diff) | |
download | mongo-485d115ac7d0c7cb50e792d7aeeff41fbe621c89.tar.gz |
SERVER-48862 Part 2: aborting index builds when a migration starts
Diffstat (limited to 'src/mongo/db/repl_index_build_state.h')
-rw-r--r-- | src/mongo/db/repl_index_build_state.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mongo/db/repl_index_build_state.h b/src/mongo/db/repl_index_build_state.h index 0afff575068..428d1f99004 100644 --- a/src/mongo/db/repl_index_build_state.h +++ b/src/mongo/db/repl_index_build_state.h @@ -87,6 +87,10 @@ enum class IndexBuildAction { */ kInitialSyncAbort, /** + * Abort signal set on donor when tenant migration starts. + */ + kTenantMigrationAbort, + /** * Abort signal set by createIndexes cmd or by drop databases/collections/indexes cmds */ kPrimaryAbort, @@ -149,13 +153,13 @@ public: /** * Transitions this index build to new 'state'. * Invariants if the requested transition is not valid and 'skipCheck' is true. - * 'timestamp' and 'abortReason' may be provided for certain states such as 'commit' and + * 'timestamp', 'abortStatus' may be provided for certain states such as 'commit' and * 'abort'. */ void setState(StateFlag state, bool skipCheck, boost::optional<Timestamp> timestamp = boost::none, - boost::optional<std::string> abortReason = boost::none); + boost::optional<Status> abortStatus = boost::none); bool isCommitPrepared() const { return _state == kPrepareCommit; @@ -178,7 +182,11 @@ public: } boost::optional<std::string> getAbortReason() const { - return _abortReason; + return boost::make_optional(!_abortStatus.isOK(), _abortStatus.reason()); + } + + Status getAbortStatus() const { + return _abortStatus; } std::string toString() const { @@ -208,8 +216,8 @@ private: // It represents the commit or abort timestamp communicated via // commitIndexBuild and abortIndexBuild oplog entry. boost::optional<Timestamp> _timestamp; - // Reason for abort reason. - boost::optional<std::string> _abortReason; + // Reason for abort, if any. + Status _abortStatus = Status::OK(); }; /** @@ -283,6 +291,11 @@ public: std::string getAbortReason() const; /** + * Returns abort status. Invariants if not in aborted state. + */ + Status getAbortStatus() const; + + /** * Called when commit quorum is satisfied. * Invokes 'onCommitQuorumSatisfied' if state is successfully transitioned to commit quorum * satisfied. |