diff --git a/aeron-cluster/src/main/java/io/aeron/cluster/ClusterBackupAgent.java b/aeron-cluster/src/main/java/io/aeron/cluster/ClusterBackupAgent.java index 0ea7837c09..3169bd2871 100644 --- a/aeron-cluster/src/main/java/io/aeron/cluster/ClusterBackupAgent.java +++ b/aeron-cluster/src/main/java/io/aeron/cluster/ClusterBackupAgent.java @@ -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; } @@ -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())