diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 190c112b32..d8566dbdb5 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -1543,6 +1543,10 @@ private void setMode(Mode m, boolean log) @VisibleForTesting void setMode(Mode m, @Safe String msg, boolean log) { + if (operationMode == Mode.NON_TRANSIENT_ERROR && m != Mode.NON_TRANSIENT_ERROR) + { + logger.warn("Attempted to change mode from NTE to non-NTE", SafeArg.of("attemptedSetMode", m), SafeArg.of("msg", msg)); + } operationMode = m; if (log) logger.info(m.toString(), SafeArg.of("msg", msg)); @@ -1599,9 +1603,23 @@ private boolean bootstrap(final Collection tokens) ListenableFuture bootstrapStream = bootstrapper.bootstrap(streamStateStore, !replacing && useStrictConsistency); // handles token update try { - bootstrapStream.get(); + while (true) + { + if (bootstrapStream.isDone()) + { + bootstrapStream.get(); + logger.info("Bootstrap streaming completed for tokens {}", tokens); + break; + } + if (hasNonTransientError(NonTransientError.BOOTSTRAP_ERROR)) + { + logger.info("Stopped waiting for bootstrap streaming to complete because detected a bootstrap error.", SafeArg.of("nonTransientErrors", getNonTransientErrors())); + break; + } + Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); + } + bootstrapStream.cancel(true); isBootstrapMode = false; - logger.info("Bootstrap streaming completed for tokens {}", tokens); return !StorageService.instance.hasNonTransientError(StorageServiceMBean.NonTransientError.BOOTSTRAP_ERROR); } catch (Throwable e)