Skip to content

feat: rework requireRestart to getActionOnUpdateTo to control restart/task-disruption behavior#19700

Merged
Fly-Style merged 6 commits into
apache:masterfrom
Fly-Style:supervisor-introduce-restart-quiet
Jul 20, 2026
Merged

feat: rework requireRestart to getActionOnUpdateTo to control restart/task-disruption behavior#19700
Fly-Style merged 6 commits into
apache:masterfrom
Fly-Style:supervisor-introduce-restart-quiet

Conversation

@Fly-Style

@Fly-Style Fly-Style commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Today, updating a supervisor spec always restarts the supervisor and terminates its running tasks, even when the change is cosmetic. This makes routine spec updates unnecessarily disruptive to in-flight ingestion.

This PR replaces the boolean SupervisorSpec#requireRestart with a tri-state SupervisorSpec#getActionOnUpdateTo(SupervisorSpec proposedSpec), returning a SupervisorSpecUpdateAction:

  • NONE - persist the new spec, no restart
  • RESTART_SUPERVISOR - restart the supervisor, but leave running tasks alone
  • RESTART_SUPERVISOR_AND_TASKS - restart the supervisor and terminate its tasks (previous behavior; still the default)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new SupervisorSpec extension point to control whether supervisor restarts (stop+recreate) should gracefully stop managed tasks, enabling certain supervisor implementations to avoid disrupting running tasks during spec updates while preserving existing default behavior.

Changes:

  • Added SupervisorSpec#shouldRestartCauseTaskDisruption() with a default of true to preserve existing behavior.
  • Threaded the new flag through SupervisorManager so restarts can call Supervisor.stop(...) with either disruptive (true) or non-disruptive (false) behavior, while termination continues to always disrupt tasks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorSpec.java Introduces the new default method used to decide whether restarts should disrupt managed tasks.
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorManager.java Wires the new flag into supervisor restart/stop flows by passing it through to Supervisor.stop(...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/**
* Returns true if the supervisor restart should cause task disruption, false otherwise
*/
default boolean shouldRestartCauseTaskDisruption()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether to restart tasks or not will depend on the difference between the current spec and proposed spec.

In some cases, we might want to rollover tasks and in other cases, we might want to continue with the existing tasks.

Suggested change
default boolean shouldRestartCauseTaskDisruption()
default boolean shouldRolloverTasksOnRestart(SupervisorSpec proposedSpec);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

private SupervisorSpec possiblyStopAndRemoveSupervisorInternal(
String id,
boolean writeTombstone,
boolean shouldRestartCauseTaskDisruption

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
boolean shouldRestartCauseTaskDisruption
boolean terminateTasks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@kfaraz

kfaraz commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@Fly-Style , since the methods requireRestart and the new one (shouldRolloverTasksOnRestart) are closely related, I wonder if we shouldn't just have a single method that returns a tri-state enum.

The requireRestart method could then be changed to:

SupervisorAction getActionOnUpdateTo(SupervisorSpec proposedSpec);

enum SupervisorAction
{
  NONE, RESTART_SUPERVISOR, RESTART_SUPERVISOR_AND_TASKS
}

The advantage is that implementers would have to implement just one method and not need to worry about how the two methods play together. The end result would be much more intuitive.

cc: @jtuglu1 , do you have any thoughts?

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 2 of 2 changed files.

Found one lifecycle race where an active autoscaler can still disrupt tasks during an opted-out restart.


This is an automated review by Codex GPT-5.6-Sol

@Fly-Style Fly-Style changed the title feat: introduce shouldRestartCauseTaskDisruption in SupervisorSpec feat: introduce shouldRolloverTasksOnRestart() in SupervisorSpec Jul 20, 2026
@Fly-Style
Fly-Style requested a review from kfaraz July 20, 2026 07:59
Comment on lines +157 to +158
default boolean shouldRolloverTasksOnRestart(SupervisorSpec proposedSpec)
{

@kfaraz kfaraz Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fly-Style , thinking some more on this, let's change the existing method requireRestart instead of adding a new method.

ref: #19700 (comment)

Let's try to merge it off soon so that we can ensure it is include it in Druid 38 to avoid multiple changes to this interface since it an extension API.

@Fly-Style Fly-Style changed the title feat: introduce shouldRolloverTasksOnRestart() in SupervisorSpec feat: rework requireRestart to getActionOnUpdateTo to control restart/task-disruption behavior Jul 20, 2026
@Fly-Style
Fly-Style requested a review from kfaraz July 20, 2026 09:41

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpicks, rest looks good!

// Always stop/recreate, persisting whenever the spec actually changed (or is new).
final boolean specChanged = isSpecChangedAndValidated(spec);
final SupervisorSpec existingSpec = possiblyStopAndRemoveSupervisorInternal(spec.getId(), false);
final Pair<Supervisor, SupervisorSpec> current = supervisors.get(spec.getId());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The skipRestartIfUnmodified flag is false by default.
So, in that case, I wonder if we shouldn't just retain current behaviour of always restarting the tasks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meanwhile, we still may have it configured with only supervisor restart.
I am voting to have the update logic, not retain what we have now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was torn between the two options myself.

But then I realized the restart here really refers to the task restart itself, since that is where the churn happens. Restarting the supervisor itself is a cheap operation.

So when skipRestart is false, user doesn't want to skip restart at all, so we should restart both tasks and supervisors.

As for the default behaviour, we can update the default value of this flag in SupervisorResource in the next release (Druid 39).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, fair

@Fly-Style

Copy link
Copy Markdown
Contributor Author

@kfaraz all comments were addressed

@Fly-Style
Fly-Style requested a review from kfaraz July 20, 2026 11:46

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

{
private final boolean modified;
private final boolean restarted;
private final SupervisorSpecUpdateAction action;

@kfaraz kfaraz Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side thought: I wonder if this field will also get serialized out even though it doesn't have a getter.

@kfaraz kfaraz added this to the 38.0.0 milestone Jul 20, 2026
@kfaraz

kfaraz commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Including this in Druid 38 to avoid unnecessary changes to the Supervisor interface between releases.

@Fly-Style
Fly-Style merged commit f0d8c61 into apache:master Jul 20, 2026
38 checks passed
@Fly-Style
Fly-Style deleted the supervisor-introduce-restart-quiet branch July 20, 2026 13:13
@github-actions github-actions Bot removed this from the 38.0.0 milestone Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants