Skip to content

Commit 99d355d

Browse files
[ML] Fix possible race condition starting datafeed
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
1 parent 96a0a2f commit 99d355d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,12 @@ private void runTask(TransportStartDatafeedAction.DatafeedTask task) {
520520
// a context with sufficient permissions would coincidentally be in force in some single node
521521
// tests, leading to bugs not caught in CI due to many tests running in single node test clusters.
522522
try (ThreadContext.StoredContext ignore = threadPool.getThreadContext().stashContext()) {
523-
innerRun(runningDatafeedsOnThisNode.get(task.getAllocationId()), task.getDatafeedStartTime(), task.getEndTime());
523+
Holder holder = runningDatafeedsOnThisNode.get(task.getAllocationId());
524+
if (holder != null) {
525+
innerRun(holder, task.getDatafeedStartTime(), task.getEndTime());
526+
} else {
527+
logger.warn("Datafeed [{}] was closed while being opened", task.getDatafeedId());
528+
}
524529
}
525530
}
526531

0 commit comments

Comments
 (0)