Skip to content

Commit

Permalink
Avoid aborting repair segments too early.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
smarsching authored and adejanovski committed Feb 18, 2020
1 parent d43aaaa commit 05e5f32
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 05e5f32

Please sign in to comment.