Skip to content

Commit

Permalink
track and handle errors during nodetool bootstrap resume properly
Browse files Browse the repository at this point in the history
patch by Leonard Ma; reviewed by Caleb Rackliffe and Aleksey Yeschenko for CASSANDRA-16491
  • Loading branch information
lmtrombone authored and maedhroz committed Oct 28, 2022
1 parent 39a4702 commit 8ec0436
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
4.2
* Nodetool bootstrap resume will now return an error if the operation fails (CASSANDRA-16491)
* Disable resumable bootstrap by default (CASSANDRA-17679)
* Include Git SHA in --verbose flag for nodetool version (CASSANDRA-17753)
* Update Byteman to 4.0.20 and Jacoco to 0.8.8 (CASSANDRA-16413)
Expand Down
13 changes: 12 additions & 1 deletion src/java/org/apache/cassandra/tools/BootstrapMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class BootstrapMonitor extends JMXNotificationProgressListener
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
private final PrintStream out;
private final Condition condition = newOneTimeCondition();
private volatile Exception error;

public BootstrapMonitor(PrintStream out)
{
Expand Down Expand Up @@ -66,7 +67,7 @@ public void handleConnectionClosed(long timestamp, String message)
@Override
public void handleConnectionFailed(long timestamp, String message)
{
Exception error = new IOException(String.format("[%s] JMX connection closed. (%s)",
error = new IOException(String.format("[%s] JMX connection closed. (%s)",
format.format(timestamp), message));
out.println(error.getMessage());
condition.signalAll();
Expand All @@ -82,9 +83,19 @@ public void progress(String tag, ProgressEvent event)
message = message + " (progress: " + (int)event.getProgressPercentage() + "%)";
}
out.println(message);
if (type == ProgressEventType.ERROR)
{
error = new RuntimeException(String.format("Bootstrap resume has failed with error: %s", message));
condition.signalAll();
}
if (type == ProgressEventType.COMPLETE)
{
condition.signalAll();
}
}

public Exception getError()
{
return error;
}
}
2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/tools/NodeProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,8 @@ public void resumeBootstrap(PrintStream out) throws IOException
{
out.println("Resuming bootstrap");
monitor.awaitCompletion();
if (monitor.getError() != null)
throw monitor.getError();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private static void bootstrap(Cluster cluster,
.failure()
.errorContains("Cannot join the ring until bootstrap completes");

node.nodetoolResult("bootstrap", "resume").asserts().failure();
RewriteEnabled.disable();
node.nodetoolResult("bootstrap", "resume").asserts().success();
if (isWriteSurvey)
Expand Down

0 comments on commit 8ec0436

Please sign in to comment.