Skip to content

Commit

Permalink
[Java] Store recordingId and commit position for failed election terms.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Feb 16, 2019
1 parent a754175 commit e305241
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aeron-cluster/src/main/java/io/aeron/cluster/Election.java
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,16 @@ else if (nowMs > (timeOfLastUpdateMs + leaderHeartbeatIntervalMs))
private int leaderTransition(final long nowMs)
{
consensusModuleAgent.becomeLeader(candidateTermId, logPosition, logSessionId);
final long recordingId = consensusModuleAgent.logRecordingId();

for (long termId = leadershipTermId + 1; termId < candidateTermId; termId++)
{
ctx.recordingLog().appendTerm(NULL_VALUE, termId, logPosition, nowMs);
ctx.recordingLog().appendTerm(recordingId, termId, logPosition, nowMs);
ctx.recordingLog().commitLogPosition(termId, logPosition);
}

leadershipTermId = candidateTermId;

ctx.recordingLog().appendTerm(consensusModuleAgent.logRecordingId(), leadershipTermId, logPosition, nowMs);
ctx.recordingLog().appendTerm(recordingId, leadershipTermId, logPosition, nowMs);
ctx.recordingLog().force();

state(State.LEADER_READY, nowMs);
Expand Down

0 comments on commit e305241

Please sign in to comment.