From 05e5f3256fffed8005fe96647b1d482a815982eb Mon Sep 17 00:00:00 2001 From: Sebastian Marsching Date: Tue, 18 Feb 2020 15:40:00 +0100 Subject: [PATCH] Avoid aborting repair segments too early. This fixes a bug where the repair of a segment would be aborted before the timeout is reached when condition.await(...) waits a bit shorter than specified. --- .../java/io/cassandrareaper/service/SegmentRunner.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/server/src/main/java/io/cassandrareaper/service/SegmentRunner.java b/src/server/src/main/java/io/cassandrareaper/service/SegmentRunner.java index 62c4bb783..524b24f68 100644 --- a/src/server/src/main/java/io/cassandrareaper/service/SegmentRunner.java +++ b/src/server/src/main/java/io/cassandrareaper/service/SegmentRunner.java @@ -396,21 +396,17 @@ private void processTriggeredSegment(final RepairSegment segment, final JmxProxy final long startTime = System.currentTimeMillis(); final long maxTime = startTime + timeoutMillis; final long waitTime = Math.min(timeoutMillis, 60000); - long lastLoopTime = startTime; while (System.currentTimeMillis() < maxTime) { - condition.await(waitTime, TimeUnit.MILLISECONDS); + boolean isDoneOrFailed = condition.await(waitTime, TimeUnit.MILLISECONDS); - boolean isDoneOrTimedOut = lastLoopTime + 60_000 > System.currentTimeMillis(); - - isDoneOrTimedOut |= RepairSegment.State.DONE == context.storage + isDoneOrFailed |= RepairSegment.State.DONE == context.storage .getRepairSegment(segment.getRunId(), segmentId).get().getState(); - if (isDoneOrTimedOut) { + if (isDoneOrFailed) { break; } renewLead(); - lastLoopTime = System.currentTimeMillis(); } } catch (InterruptedException e) { LOG.warn("Repair command {} on segment {} interrupted", this.repairNo, segmentId, e);