Skip to content

Commit

Permalink
[7.4][ML] Ensure data frame analytics task is only marked completed o…
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitris-athanasiou committed Sep 26, 2019
1 parent 7ada968 commit cb836a0
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ public static class DataFrameAnalyticsTask extends AllocatedPersistentTask imple
private volatile Long reindexingTaskId;
private volatile boolean isReindexingFinished;
private volatile boolean isStopping;
private volatile boolean isMarkAsCompletedCalled;
private final ProgressTracker progressTracker = new ProgressTracker();

public DataFrameAnalyticsTask(long id, String type, String action, TaskId parentTask, Map<String, String> headers,
Expand Down Expand Up @@ -460,10 +461,17 @@ protected void onCancelled() {
public void markAsCompleted() {
// It is possible that the stop API has been called in the meantime and that
// may also cause this method to be called. We check whether we have already
// been marked completed to avoid doing it twice.
if (isCompleted() == false) {
persistProgress(() -> super.markAsCompleted());
// been marked completed to avoid doing it twice. We need to capture that
// locally instead of relying to isCompleted() because of the asynchronous
// persistence of progress.
synchronized (this) {
if (isMarkAsCompletedCalled) {
return;
}
isMarkAsCompletedCalled = true;
}

persistProgress(() -> super.markAsCompleted());
}

@Override
Expand Down

0 comments on commit cb836a0

Please sign in to comment.