Stop renew retention leases when follow task fails (#65168)

If a shard follow-task hits a non-retryable error and stops, then we 
should also stop the retention-leases renewal process associated with
that follow-task.
This commit is contained in:
Nhat Nguyen 2020-11-17 21:03:07 -05:00
parent 2e079b1b9b
commit 3989243a52
3 changed files with 12 additions and 5 deletions

View File

@ -531,12 +531,18 @@ public abstract class ShardFollowNodeTask extends AllocatedPersistentTask {
scheduler.accept(TimeValue.timeValueMillis(delay), task);
}
} else {
setFatalException(e);
onFatalFailure(e);
}
}
void setFatalException(Exception e) {
fatalException = ExceptionsHelper.convertToElastic(e);
final void onFatalFailure(Exception e) {
synchronized (this) {
this.fatalException = ExceptionsHelper.convertToElastic(e);
if (this.renewable != null) {
this.renewable.cancel();
this.renewable = null;
}
}
LOGGER.warn("shard follow task encounter non-retryable error", e);
}

View File

@ -546,7 +546,7 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor<ShardFollo
shardFollowNodeTask), e);
threadPool.schedule(() -> nodeOperation(task, params, state), params.getMaxRetryDelay(), Ccr.CCR_THREAD_POOL_NAME);
} else {
shardFollowNodeTask.setFatalException(e);
shardFollowNodeTask.onFatalFailure(e);
}
};

View File

@ -1007,7 +1007,7 @@ public class ShardFollowNodeTaskTests extends ESTestCase {
assertThat(status.followerGlobalCheckpoint(), equalTo(-1L));
}
public void testNonRetryableError() {
public void testNonRetryableError() throws Exception {
ShardFollowTaskParams params = new ShardFollowTaskParams();
params.maxReadRequestOperationCount = 64;
params.maxOutstandingReadRequests = 1;
@ -1031,6 +1031,7 @@ public class ShardFollowNodeTaskTests extends ESTestCase {
ShardFollowNodeTaskStatus status = task.getStatus();
assertThat(status.outstandingWriteRequests(), equalTo(1));
assertThat(status.followerGlobalCheckpoint(), equalTo(-1L));
assertBusy(() -> assertNull(task.getRenewable()));
}
public void testMaxWriteRequestSize() {