-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add group_id to the sys.tasks table #8304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fc0b974
f044610
777b784
70aa55b
31deac6
cc1b654
2e0b234
2c7b366
5228f38
591e9db
5238706
8a920ec
50d5d9f
175b1fb
229c5af
f369a92
de1d6be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,7 +203,7 @@ public List<TaskInfo<Task, TaskStatus>> getActiveTaskInfo(@Nullable String dataS | |
| final ImmutableList.Builder<TaskInfo<Task, TaskStatus>> listBuilder = ImmutableList.builder(); | ||
| for (final TaskStuff taskStuff : tasks.values()) { | ||
| if (taskStuff.getStatus().isRunnable()) { | ||
| TaskInfo t = new TaskInfo( | ||
| TaskInfo t = new TaskInfo<>( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for fixing! |
||
| taskStuff.getTask().getId(), | ||
| taskStuff.getCreatedDate(), | ||
| taskStuff.getStatus(), | ||
|
|
@@ -267,7 +267,7 @@ private List<TaskInfo<Task, TaskStatus>> getRecentlyCreatedAlreadyFinishedTaskIn | |
| final ImmutableList.Builder<TaskInfo<Task, TaskStatus>> listBuilder = ImmutableList.builder(); | ||
| for (final TaskStuff taskStuff : list) { | ||
| String id = taskStuff.getTask().getId(); | ||
| TaskInfo t = new TaskInfo( | ||
| TaskInfo t = new TaskInfo<>( | ||
| id, | ||
| taskStuff.getCreatedDate(), | ||
| taskStuff.getStatus(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,7 +215,8 @@ public List<TaskInfo<Task, TaskStatus>> getRecentlyCreatedAlreadyFinishedTaskInf | |
| { | ||
| return ImmutableList.copyOf( | ||
| handler.getCompletedTaskInfo( | ||
| DateTimes.nowUtc().minus(durationBeforeNow == null ? config.getRecentlyFinishedThreshold() : durationBeforeNow), | ||
| DateTimes.nowUtc() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for reformatting! |
||
| .minus(durationBeforeNow == null ? config.getRecentlyFinishedThreshold() : durationBeforeNow), | ||
| maxTaskStatuses, | ||
| datasource | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| package org.apache.druid.indexing.common.task.batch.parallel; | ||
|
|
||
| import com.google.common.base.Optional; | ||
| import com.google.common.base.Throwables; | ||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.common.collect.ImmutableMap; | ||
|
|
@@ -52,6 +53,7 @@ | |
| import org.apache.druid.java.util.common.DateTimes; | ||
| import org.apache.druid.java.util.common.ISE; | ||
| import org.apache.druid.java.util.common.concurrent.Execs; | ||
| import org.apache.druid.metadata.EntryExistsException; | ||
| import org.apache.druid.segment.loading.LocalDataSegmentPusher; | ||
| import org.apache.druid.segment.loading.LocalDataSegmentPusherConfig; | ||
| import org.apache.druid.segment.loading.NoopDataSegmentKiller; | ||
|
|
@@ -138,16 +140,24 @@ class LocalIndexingServiceClient extends NoopIndexingServiceClient | |
| public String runTask(Object taskObject) | ||
| { | ||
| final Task subTask = (Task) taskObject; | ||
| try { | ||
| getTaskStorage().insert(subTask, TaskStatus.running(subTask.getId())); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the subtask only starts running after
If those scenarios need to be considered, then added tests for them will be useful.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, good point, I set the task status to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, this is a test class, so my earlier comment can be disregarded |
||
| } | ||
| catch (EntryExistsException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| tasks.put(subTask.getId(), service.submit(() -> { | ||
| try { | ||
| final TaskToolbox toolbox = createTaskToolbox(subTask); | ||
| if (subTask.isReady(toolbox.getTaskActionClient())) { | ||
| return subTask.run(toolbox); | ||
| } else { | ||
| getTaskStorage().setStatus(TaskStatus.failure(subTask.getId())); | ||
| throw new ISE("task[%s] is not ready", subTask.getId()); | ||
| } | ||
| } | ||
| catch (Exception e) { | ||
| getTaskStorage().setStatus(TaskStatus.failure(subTask.getId(), e.getMessage())); | ||
| throw new RuntimeException(e); | ||
| } | ||
| })); | ||
|
|
@@ -158,6 +168,8 @@ public String runTask(Object taskObject) | |
| public TaskStatusResponse getTaskStatus(String taskId) | ||
| { | ||
| final Future<TaskStatus> taskStatusFuture = tasks.get(taskId); | ||
| final Optional<Task> task = getTaskStorage().getTask(taskId); | ||
| final String groupId = task.isPresent() ? task.get().getGroupId() : null; | ||
| if (taskStatusFuture != null) { | ||
| try { | ||
| if (taskStatusFuture.isDone()) { | ||
|
|
@@ -166,6 +178,7 @@ public TaskStatusResponse getTaskStatus(String taskId) | |
| taskId, | ||
| new TaskStatusPlus( | ||
| taskId, | ||
| groupId, | ||
| SinglePhaseSubTask.TYPE, | ||
| DateTimes.EPOCH, | ||
| DateTimes.EPOCH, | ||
|
|
@@ -182,6 +195,7 @@ public TaskStatusResponse getTaskStatus(String taskId) | |
| taskId, | ||
| new TaskStatusPlus( | ||
| taskId, | ||
| groupId, | ||
| SinglePhaseSubTask.TYPE, | ||
| DateTimes.EPOCH, | ||
| DateTimes.EPOCH, | ||
|
|
@@ -203,6 +217,7 @@ public TaskStatusResponse getTaskStatus(String taskId) | |
| taskId, | ||
| new TaskStatusPlus( | ||
| taskId, | ||
| groupId, | ||
| SinglePhaseSubTask.TYPE, | ||
| DateTimes.EPOCH, | ||
| DateTimes.EPOCH, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,7 @@ public TaskStatusResponse getTaskStatus(String taskId) | |
| taskId, | ||
| new TaskStatusPlus( | ||
| taskId, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is If
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it might be fine to use the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this particular test, the groupId is always |
||
| "groupId", | ||
| "testTask", | ||
| DateTimes.EPOCH, | ||
| DateTimes.EPOCH, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1001,7 +1001,13 @@ public void testGetTaskStatus() throws Exception | |
| final TaskStatus status = TaskStatus.running("mytask"); | ||
|
|
||
| EasyMock.expect(taskStorageQueryAdapter.getTaskInfo("mytask")) | ||
| .andReturn(new TaskInfo<>(task.getId(), DateTimes.of("2018-01-01"), status, task.getDataSource(), task)); | ||
| .andReturn(new TaskInfo( | ||
| task.getId(), | ||
| DateTimes.of("2018-01-01"), | ||
| status, | ||
| task.getDataSource(), | ||
| task | ||
| )); | ||
|
|
||
| EasyMock.expect(taskStorageQueryAdapter.getTaskInfo("othertask")) | ||
| .andReturn(null); | ||
|
|
@@ -1029,6 +1035,7 @@ public void testGetTaskStatus() throws Exception | |
| new TaskStatusResponse( | ||
| "mytask", | ||
| new TaskStatusPlus( | ||
| "mytask", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar comment here about
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here, it does matter, the value of |
||
| "mytask", | ||
| "noop", | ||
| DateTimes.of("2018-01-01"), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a more intuitive name for users to understand would be
parentId? Renaming it toparentIdwill also resemble the parent process id concept of most operating systems that many users are familiar with. For non-subtasks, the value would default to the empty string instead of the task id.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds an interesting idea, but I'm not sure if it would make sense with Kafka/Kinesis indexing tasks. The kafka/kinesis supervisor spawns indexing tasks but the supervisor is executed using a thread in the overlord. The tasks have the same groupId which is
datasourcename where they ingest data into.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't know there's already a notion of task groups. For consistency, we should continue using "group" then.