Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Retry Legacy Sweep Iterations (#5655)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaretic authored Sep 23, 2021
1 parent 396611a commit a5f1f68
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
package com.palantir.atlasdb.sweep;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.palantir.atlasdb.encoding.PtBytes;
import com.palantir.atlasdb.keyvalue.api.KeyValueService;
import com.palantir.atlasdb.keyvalue.api.RetryLimitReachedException;
import com.palantir.atlasdb.keyvalue.api.SweepResults;
import com.palantir.atlasdb.keyvalue.api.TableReference;
import com.palantir.atlasdb.logging.LoggingArgs;
Expand Down Expand Up @@ -126,16 +128,23 @@ void runOnceAndSaveResults(TableToSweep tableToSweep, SweepBatchConfig batchConf

SweepResults runOneIteration(
TableReference tableRef, byte[] startRow, SweepBatchConfig batchConfig, SweepTaskRunner.RunType runType) {
try {
SweepResults results = sweepRunner.run(tableRef, batchConfig, startRow, runType);
logSweepPerformance(tableRef, startRow, results);
for (int attempts = 0; attempts < 100; attempts++) {
try {
SweepResults results = sweepRunner.run(tableRef, batchConfig, startRow, runType);
logSweepPerformance(tableRef, startRow, results);

return results;
} catch (RuntimeException e) {
// This error may be logged on some paths above, but I prefer to log defensively.
logSweepError(tableRef, startRow, batchConfig, e);
throw e;
return results;
} catch (RuntimeException e) {
logSweepError(tableRef, startRow, batchConfig, e);
try {
Thread.sleep(5000);
} catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
throw e;
}
}
}
throw new RetryLimitReachedException(ImmutableList.of());
}

private void logSweepPerformance(TableReference tableRef, byte[] startRow, SweepResults results) {
Expand Down

0 comments on commit a5f1f68

Please sign in to comment.