This is an automated email from the ASF dual-hosted git repository.
kfaraz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 296eaceec08 Fix race in TaskQueue between management and sync loops
(#18020)
296eaceec08 is described below
commit 296eaceec08093171f5e9074682828ec096dadcc
Author: jtuglu-netflix <[email protected]>
AuthorDate: Tue May 20 01:14:23 2025 -0700
Fix race in TaskQueue between management and sync loops (#18020)
---
.../main/java/org/apache/druid/indexing/overlord/TaskQueue.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
index 260b34330d0..517835c0090 100644
---
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
+++
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskQueue.java
@@ -531,6 +531,8 @@ public class TaskQueue
// insert the task into our queue. So don't catch it.
final DateTime insertTime = DateTimes.nowUtc();
taskStorage.insert(task, TaskStatus.running(task.getId()));
+ // Note: the TaskEntry created for this task doesn't actually use the
`insertTime` timestamp, it uses a new
+ // timestamp created in the ctor. This prevents races from occurring
while syncFromStorage() is happening.
addTaskInternal(task, insertTime);
requestManagement();
return true;
@@ -585,10 +587,11 @@ public class TaskQueue
// Remove the task only if it doesn't have a more recent update
if (prevEntry != null &&
prevEntry.lastUpdatedTime.isBefore(deleteTime)) {
removedTask.set(prevEntry.task);
+ // Remove this taskId from activeTasks by mapping it to null
+ return null;
}
-
- // Remove this taskId from activeTasks by mapping it to null
- return null;
+ // Preserve this taskId by returning the same reference
+ return prevEntry;
}
);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]