Skip to content

Commit 283fdea

Browse files
author
Andrey Ershov
committed
Reset lastFailedJoinAttempt
1 parent 83f1bb5 commit 283fdea

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.util.Map;
6060
import java.util.Optional;
6161
import java.util.Set;
62+
import java.util.concurrent.atomic.AtomicReference;
6263
import java.util.function.BiConsumer;
6364
import java.util.function.Function;
6465
import java.util.function.LongSupplier;
@@ -84,7 +85,7 @@ public class JoinHelper {
8485

8586
final Set<Tuple<DiscoveryNode, JoinRequest>> pendingOutgoingJoins = ConcurrentCollections.newConcurrentSet();
8687

87-
private volatile FailedJoinAttempt lastFailedJoinAttempt;
88+
private AtomicReference<FailedJoinAttempt> lastFailedJoinAttempt = new AtomicReference<>();
8889

8990
JoinHelper(Settings settings, AllocationService allocationService, MasterService masterService,
9091
TransportService transportService, LongSupplier currentTermSupplier, Supplier<ClusterState> currentStateSupplier,
@@ -217,9 +218,10 @@ void logWarnWithTimestamp() {
217218

218219

219220
void logLastFailedJoinAttempt() {
220-
FailedJoinAttempt attempt = lastFailedJoinAttempt;
221+
FailedJoinAttempt attempt = lastFailedJoinAttempt.get();
221222
if (attempt != null) {
222223
attempt.logWarnWithTimestamp();
224+
lastFailedJoinAttempt.compareAndSet(attempt, null);
223225
}
224226
}
225227

@@ -241,15 +243,15 @@ public Empty read(StreamInput in) {
241243
public void handleResponse(Empty response) {
242244
pendingOutgoingJoins.remove(dedupKey);
243245
logger.debug("successfully joined {} with {}", destination, joinRequest);
244-
lastFailedJoinAttempt = null;
246+
lastFailedJoinAttempt.set(null);
245247
}
246248

247249
@Override
248250
public void handleException(TransportException exp) {
249251
pendingOutgoingJoins.remove(dedupKey);
250252
FailedJoinAttempt attempt = new FailedJoinAttempt(destination, joinRequest, exp);
251253
attempt.logNow();
252-
lastFailedJoinAttempt = attempt;
254+
lastFailedJoinAttempt.set(attempt);
253255
}
254256

255257
@Override

0 commit comments

Comments
 (0)