Skip to content

Commit

Permalink
if appendLog failed after rpc return, use a different error code (ves…
Browse files Browse the repository at this point in the history
…oft-inc#626)

Co-authored-by: Doodle <13706157+critical27@users.noreply.github.com>

Co-authored-by: lionel.liu@vesoft.com <52276794+liuyu85cn@users.noreply.github.com>
Co-authored-by: Doodle <13706157+critical27@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 21, 2022
1 parent 44677ab commit 8ba7183
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/interface/common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ enum ErrorCode {
E_RAFT_LOG_GAP = -3501,
E_RAFT_LOG_STALE = -3502,
E_RAFT_TERM_OUT_OF_DATE = -3503,
E_RAFT_UNKNOWN_APPEND_LOG = -3504,
// Raft state errors
E_RAFT_WAITING_SNAPSHOT = -3511,
E_RAFT_SENDING_SNAPSHOT = -3512,
Expand Down
7 changes: 6 additions & 1 deletion src/kvstore/raftex/RaftPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,12 @@ void RaftPart::processAppendLogResponses(const AppendLogResponses& resps,
leader_ = HostAddr("", 0);
lastLogId_ = wal_->lastLogId();
lastLogTerm_ = wal_->lastLogTerm();
res = nebula::cpp2::ErrorCode::E_RAFT_TERM_OUT_OF_DATE;
// It is nature to return E_RAFT_TERM_OUT_OF_DATE or LEADER_CHANGE
// here, but this will make caller believe this append failed
// however, this log is replicated to followers(written in WAL)
// and those followers may become leader (use that WAL)
// which means this log may actully commit succeeded.
res = nebula::cpp2::ErrorCode::E_RAFT_UNKNOWN_APPEND_LOG;
}
}
if (!checkAppendLogResult(res)) {
Expand Down

0 comments on commit 8ba7183

Please sign in to comment.