Skip to content

Commit

Permalink
[Java] Send appVersion in the NewLeadershipTerm.
Browse files Browse the repository at this point in the history
Fixes #1671
  • Loading branch information
vyazelenko committed Nov 7, 2024
1 parent b07b194 commit 986bcbf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ else if (Cluster.Role.LEADER == role)
clusterClock.time(),
memberId,
logPublisher.sessionId(),
ctx.appVersion(),
false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void newLeadershipTerm(
final long timestamp,
final int leaderMemberId,
final int logSessionId,
final int appVersion,
final boolean isStartup)
{
if (null == publication)
Expand Down Expand Up @@ -214,6 +215,7 @@ void newLeadershipTerm(
.timestamp(timestamp)
.leaderMemberId(leaderMemberId)
.logSessionId(logSessionId)
.appVersion(appVersion)
.isStartup(isStartup ? BooleanType.TRUE : BooleanType.FALSE);

bufferClaim.commit();
Expand Down
1 change: 1 addition & 0 deletions aeron-cluster/src/main/java/io/aeron/cluster/Election.java
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ private void publishNewLeadershipTerm(
timestamp,
thisMember.id(),
logSessionId,
ctx.appVersion(),
isLeaderStartup);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ void shouldElectAppointedLeader()
{
final long leadershipTermId = NULL_VALUE;
final long logPosition = 0;
final int appVersion = -98;
final ClusterMember[] clusterMembers = prepareClusterMembers();
final ClusterMember candidateMember = clusterMembers[0];
when(consensusModuleAgent.logRecordingId()).thenReturn(RECORDING_ID);

ctx.appointedLeaderId(candidateMember.id());
ctx.appointedLeaderId(candidateMember.id()).appVersion(appVersion);

final Election election = newElection(leadershipTermId, logPosition, clusterMembers, candidateMember);

Expand Down Expand Up @@ -203,6 +204,7 @@ void shouldElectAppointedLeader()
clock.nanoTime(),
candidateMember.id(),
LOG_SESSION_ID,
appVersion,
election.isLeaderStartup());

verify(consensusPublisher).newLeadershipTerm(
Expand All @@ -218,6 +220,7 @@ void shouldElectAppointedLeader()
clock.nanoTime(),
candidateMember.id(),
LOG_SESSION_ID,
appVersion,
election.isLeaderStartup());

when(recordingLog.isUnknown(candidateTermId)).thenReturn(Boolean.TRUE);
Expand Down Expand Up @@ -1381,6 +1384,8 @@ void leaderShouldMoveToLogReplicationThenWaitForCommitPosition()
final ClusterMember liveFollower = clusterMembers[1];
final int leaderId = thisMember.id();
final int followerId = liveFollower.id();
final int appVersion = 888;
ctx.appVersion(appVersion);

when(consensusModuleAgent.role()).thenReturn(Cluster.Role.LEADER);
when(consensusModuleAgent.logRecordingId()).thenReturn(RECORDING_ID);
Expand Down Expand Up @@ -1444,6 +1449,7 @@ void leaderShouldMoveToLogReplicationThenWaitForCommitPosition()
clock.nanoTime(),
leaderId,
LOG_SESSION_ID,
appVersion,
election.isLeaderStartup());

verify(consensusPublisher).newLeadershipTerm(
Expand All @@ -1459,6 +1465,7 @@ void leaderShouldMoveToLogReplicationThenWaitForCommitPosition()
clock.nanoTime(),
leaderId,
LOG_SESSION_ID,
appVersion,
election.isLeaderStartup());

// Begin replay once a quorum of followers has caught up.
Expand Down

0 comments on commit 986bcbf

Please sign in to comment.