You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "suneet-s (via GitHub)" <gi...@apache.org> on 2023/06/08 20:28:43 UTC
[GitHub] [druid] suneet-s opened a new pull request, #14396: Supervisors restart tasks one at a time
suneet-s opened a new pull request, #14396:
URL: https://github.com/apache/druid/pull/14396
This change is still WIP. It's only been tested in local clusters. And it hasn't been tested with the lag based auto-scaler.
### Description
Currently, the number of slots needed for for a streaming supervisor to handover quickly is 2 * number of tasks needed for reading from the stream. This is because when the taskDuration expires, the previously reading tasks need to publish the segments, and if this takes time, and there are no available slots on the cluster, Druid will not be reading from the stream until a slot is available.
This change makes it so that during regular operations, tasks are rolled over one at a time, so that an operator can plan to have a capacity of number of tasks need to read from the stream + 1.
It seems like different clusters might have different preferences for whether one task at a time is sufficiently fast enough, so I think making this part of the ioConfig seems like a better approach than a hardcoded option.
#### Release note
<!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users.
If your change doesn't have end user impact, you can skip this section.
For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes).
-->
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Rolling Supervisor restarts at taskDuration (druid)
Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm commented on code in PR #14396:
URL: https://github.com/apache/druid/pull/14396#discussion_r1251333978
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -2950,21 +2959,21 @@ private void checkTaskDuration() throws ExecutionException, InterruptedException
}
}
-
- boolean stopTasksEarly = false;
- if (earlyStopTime != null && (earlyStopTime.isBeforeNow() || earlyStopTime.isEqualNow())) {
- log.info("Early stop requested - signalling tasks to complete");
-
- earlyStopTime = null;
- stopTasksEarly = true;
- }
-
-
- // if this task has run longer than the configured duration, signal all tasks in the group to persist
- if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow() || stopTasksEarly) {
+ if (stopTasksEarly) {
log.info("Task group [%d] has run for [%s]", groupId, ioConfig.getTaskDuration());
Review Comment:
If tasks are stopped early then this log line is incorrect?
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -2950,21 +2959,21 @@ private void checkTaskDuration() throws ExecutionException, InterruptedException
}
}
-
- boolean stopTasksEarly = false;
- if (earlyStopTime != null && (earlyStopTime.isBeforeNow() || earlyStopTime.isEqualNow())) {
- log.info("Early stop requested - signalling tasks to complete");
-
- earlyStopTime = null;
- stopTasksEarly = true;
- }
-
-
- // if this task has run longer than the configured duration, signal all tasks in the group to persist
- if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow() || stopTasksEarly) {
+ if (stopTasksEarly) {
log.info("Task group [%d] has run for [%s]", groupId, ioConfig.getTaskDuration());
futureGroupIds.add(groupId);
futures.add(checkpointTaskGroup(group, true));
+ } else if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow()) {
+ // if this task has run longer than the configured duration
+ // as long as the pending task groups are less than the configured stop task count.
+ if (ioConfig.getStopTaskCount() == ioConfig.getTaskCount()
+ || pendingCompletionTaskGroups.values().stream().mapToInt(CopyOnWriteArrayList::size).sum()
Review Comment:
Doesn't pendingCompletionTaskGroups gets updated outside of this loop? meaning that you would add all tasks to be checkpoint before pendingCompletionTaskGroups gets updated?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Rolling Supervisor restarts at taskDuration (druid)
Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm commented on code in PR #14396:
URL: https://github.com/apache/druid/pull/14396#discussion_r1265776267
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -2950,21 +2959,21 @@ private void checkTaskDuration() throws ExecutionException, InterruptedException
}
}
-
- boolean stopTasksEarly = false;
- if (earlyStopTime != null && (earlyStopTime.isBeforeNow() || earlyStopTime.isEqualNow())) {
- log.info("Early stop requested - signalling tasks to complete");
-
- earlyStopTime = null;
- stopTasksEarly = true;
- }
-
-
- // if this task has run longer than the configured duration, signal all tasks in the group to persist
- if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow() || stopTasksEarly) {
+ if (stopTasksEarly) {
log.info("Task group [%d] has run for [%s]", groupId, ioConfig.getTaskDuration());
futureGroupIds.add(groupId);
futures.add(checkpointTaskGroup(group, true));
+ } else if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow()) {
+ // if this task has run longer than the configured duration
+ // as long as the pending task groups are less than the configured stop task count.
+ if (ioConfig.getStopTaskCount() == ioConfig.getTaskCount()
+ || pendingCompletionTaskGroups.values().stream().mapToInt(CopyOnWriteArrayList::size).sum()
Review Comment:
ah! I missed the `break`. Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Rolling Supervisor restarts at taskDuration (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on PR #14396:
URL: https://github.com/apache/druid/pull/14396#issuecomment-1636199440
> I am +1 on not having this on by default (default would still be the current behavior) and having the config as number of tasks to roll at one time configurable per each supervisor). I am -1 on this PR as a whole due to the lack in unit testing for when the new config is used. I also have a few minor questions.
I looked into writing tests for this and struggled. SeekableStreamSupervisor is a huge abstract class, and the part that needs testing uses `DateTime.now` which isn't very testable, so I would need to refactor the class to use a Clock to simulate time passing by. It feels like trying to make this class testable introduces more risk. I even looked at adding an integration test, but it seemed like that would be flaky and take a long time to run as we would have to prove that there was no more than 1 task handing over at a time.
If there are any suggestions or pointers on how to write tests for this class, I'm open to trying it out. Otherwise, I think the fact that this is disabled by default and undocumented provides the safety net we need that it won't break for Druid users.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] abhishekagarwal87 commented on pull request #14396: WIP Supervisors restart tasks one at a time
Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 commented on PR #14396:
URL: https://github.com/apache/druid/pull/14396#issuecomment-1586943374
It will be really nice capability as it will make task scheduling more seamless. But is there going to be any drawback of this change? If the tasks start in a staggered fashion, would that affect processing throughput in any way?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Rolling Supervisor restarts at taskDuration (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on code in PR #14396:
URL: https://github.com/apache/druid/pull/14396#discussion_r1263236416
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -2950,21 +2959,21 @@ private void checkTaskDuration() throws ExecutionException, InterruptedException
}
}
-
- boolean stopTasksEarly = false;
- if (earlyStopTime != null && (earlyStopTime.isBeforeNow() || earlyStopTime.isEqualNow())) {
- log.info("Early stop requested - signalling tasks to complete");
-
- earlyStopTime = null;
- stopTasksEarly = true;
- }
-
-
- // if this task has run longer than the configured duration, signal all tasks in the group to persist
- if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow() || stopTasksEarly) {
+ if (stopTasksEarly) {
log.info("Task group [%d] has run for [%s]", groupId, ioConfig.getTaskDuration());
Review Comment:
I think the log is still correct, the task group is being stopped. On line 2944 there is a log line that indicates the task groups are stopping because an early stop was requested
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s commented on pull request #14396: WIP Supervisors restart tasks one at a time
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on PR #14396:
URL: https://github.com/apache/druid/pull/14396#issuecomment-1591754667
> But is there going to be any drawback of this change? If the tasks start in a staggered fashion, would that affect processing throughput in any way?
None that I can think of. The only thing I can imagine is if tasks are stuck in pending for such a long time, that it takes longer than the configured task handoff for all the tasks to cycle. But in that case, the tasks are still restarted from the earliest to latest, so I suspect everything should be ok.
Each kafka task is handling reading form the partitions independently, so this should have no impact on ingestion throughput
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Rolling Supervisor restarts at taskDuration (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s merged PR #14396:
URL: https://github.com/apache/druid/pull/14396
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Rolling Supervisor restarts at taskDuration (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on code in PR #14396:
URL: https://github.com/apache/druid/pull/14396#discussion_r1263241943
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -2950,21 +2959,21 @@ private void checkTaskDuration() throws ExecutionException, InterruptedException
}
}
-
- boolean stopTasksEarly = false;
- if (earlyStopTime != null && (earlyStopTime.isBeforeNow() || earlyStopTime.isEqualNow())) {
- log.info("Early stop requested - signalling tasks to complete");
-
- earlyStopTime = null;
- stopTasksEarly = true;
- }
-
-
- // if this task has run longer than the configured duration, signal all tasks in the group to persist
- if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow() || stopTasksEarly) {
+ if (stopTasksEarly) {
log.info("Task group [%d] has run for [%s]", groupId, ioConfig.getTaskDuration());
futureGroupIds.add(groupId);
futures.add(checkpointTaskGroup(group, true));
+ } else if (earliestTaskStart.plus(ioConfig.getTaskDuration()).isBeforeNow()) {
+ // if this task has run longer than the configured duration
+ // as long as the pending task groups are less than the configured stop task count.
+ if (ioConfig.getStopTaskCount() == ioConfig.getTaskCount()
+ || pendingCompletionTaskGroups.values().stream().mapToInt(CopyOnWriteArrayList::size).sum()
Review Comment:
The `break` on line 2976 makes it so that pendingCompletionTasksGroup is updated, and other tasks are stopped on the next call of `RunNotice#handle`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org