Skip to content

Commit

Permalink
[ML] Fix possible race condition starting datafeed
Browse files Browse the repository at this point in the history
Datafeeds being closed while starting could result in and NPE. This was
handled as any other failure, masking out the NPE. However, this
conflicts with the changes in elastic#50886.

Related to elastic#50886 and elastic#51302
  • Loading branch information
henningandersen committed Jan 29, 2020
1 parent 96a0a2f commit 99d355d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,12 @@ private void runTask(TransportStartDatafeedAction.DatafeedTask task) {
// a context with sufficient permissions would coincidentally be in force in some single node
// tests, leading to bugs not caught in CI due to many tests running in single node test clusters.
try (ThreadContext.StoredContext ignore = threadPool.getThreadContext().stashContext()) {
innerRun(runningDatafeedsOnThisNode.get(task.getAllocationId()), task.getDatafeedStartTime(), task.getEndTime());
Holder holder = runningDatafeedsOnThisNode.get(task.getAllocationId());
if (holder != null) {
innerRun(holder, task.getDatafeedStartTime(), task.getEndTime());
} else {
logger.warn("Datafeed [{}] was closed while being opened", task.getDatafeedId());
}
}
}

Expand Down

0 comments on commit 99d355d

Please sign in to comment.