Skip to content

Commit

Permalink
[Java] Do not close Cluster archive when doing next rounds of backup …
Browse files Browse the repository at this point in the history
…queries since the replay might still be active. Also do not switch to `RESET_BACKUP` state unless the current Cluster node has switched its role and therefore is no longer eligible for replay.
  • Loading branch information
vyazelenko committed Jan 17, 2025
1 parent e9d9896 commit cd563dc
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,16 @@ private void onBackupResponse(
else if (!logSourceValidator.isAcceptable(leaderMemberId, memberId))
{
consensusPublicationGroup.closeAndExcludeCurrent();
state(RESET_BACKUP, epochClock.time());
if (null != logSupplierMember && logSupplierMember.id() == memberId)
{
// we can no longer replay from the current node due to the role change
state(RESET_BACKUP, epochClock.time());
}
else
{
// just query another node
timeOfLastBackupQueryMs = 0;
}
return;
}

Expand Down Expand Up @@ -668,15 +677,9 @@ private int backupQuery(final long nowMs)
{
if (null == consensusPublicationGroup.current() || nowMs > (timeOfLastBackupQueryMs + backupResponseTimeoutMs))
{
CloseHelper.close(ctx.countedErrorHandler(), clusterArchiveAsyncConnect);
CloseHelper.close(ctx.countedErrorHandler(), clusterArchive);
clusterArchiveAsyncConnect = null;
clusterArchive = null;

consensusPublicationGroup.next(aeron);
correlationId = NULL_VALUE;
timeOfLastBackupQueryMs = nowMs;

return 1;
}
else if (NULL_VALUE == correlationId && consensusPublicationGroup.isConnected())
Expand Down

0 comments on commit cd563dc

Please sign in to comment.