Skip to content

fix: Precedence of taskCount, taskCountStart, taskCountMin.#19417

Merged
gianm merged 1 commit into
apache:masterfrom
gianm:fix-task-count-persistence
May 6, 2026
Merged

fix: Precedence of taskCount, taskCountStart, taskCountMin.#19417
gianm merged 1 commit into
apache:masterfrom
gianm:fix-task-count-persistence

Conversation

@gianm

@gianm gianm commented May 6, 2026

Copy link
Copy Markdown
Contributor

PR #18745 included a discussion of desired behavior of taskCount, taskCountStart, and taskCountMin, but this has not been fully implemented. There are two missed cases:

  1. On OL / supervisor restart, the persisted taskCount should be used. Currently, the persisted taskCountStart is used instead if set.

  2. On supervisor POST, the previous spec's taskCount should be used if the user provides neither taskCount nor taskCountStart. Currently, in this case, the user's provided taskCountMin is used instead.

In addition, and related to (1), currently deserialization of the ioConfig causes the taskCount to be overwritten by the taskCountStart. This causes the get supervisor and supervisor history APIs to return inaccurate taskCounts.

This patch fixes these issues by doing two things:

  1. Update SeekableStreamSupervisorIOConfig to always retain taskCount from the constructor (i.e. when deserializing) if set.

  2. Update SeekableStreamSupervisorSpec#merge to handle the special case that taskCountStart has priority on POST.

PR apache#18745 included a discussion of desired behavior of taskCount,
taskCountStart, and taskCountMin, but this has not been fully
implemented. There are two missed cases:

1) On OL / supervisor restart, the persisted taskCount should be used.
   Currently, the persisted taskCountStart is used instead if set.

2) On supervisor POST, the previous spec's taskCount should be used if
   the user provides neither taskCount nor taskCountStart. Currently,
   in this case, the user's provided taskCountMin is used instead.

In addition, and related to (1), currently deserialization of the
ioConfig causes the taskCount to be overwritten by the taskCountStart.
This causes the get supervisor and supervisor history APIs to return
inaccurate taskCounts.

This patch fixes these issues by doing two things:

1) Update SeekableStreamSupervisorIOConfig to always retain taskCount
   from the constructor (i.e. when deserializing) if set.

2) Update SeekableStreamSupervisorSpec#merge to handle the special
   case that taskCountStart has priority on POST.
@gianm
gianm force-pushed the fix-task-count-persistence branch from 0c8b706 to 159f227 Compare May 6, 2026 07:42
@gianm gianm changed the title fix: Precedence of taskCount and taskCountStart. fix: Precedence of taskCount, taskCountStart, taskCountMIn. May 6, 2026
@gianm gianm changed the title fix: Precedence of taskCount, taskCountStart, taskCountMIn. fix: Precedence of taskCount, taskCountStart, taskCountMin. May 6, 2026
if (autoScalerEnabled) {
// Priority: taskCountStart > taskCount > taskCountMin
this.taskCountExplicit = taskCount != null;
if (taskCount != null) {

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.

nit: may use this.taskCountExplicit for condition

this.taskCount = Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin());
} else {
this.taskCount = Configs.valueOrDefault(taskCount, 1);
this.taskCount = 1;

@Fly-Style Fly-Style May 6, 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.

Why this change? Autoscaler also may be disabled, but spec may not be null (available).
Isn't it better to assign 1 only as a last resort?
AFAIR, this LOC in this verrsion led to some inaccurate behaviour some time ago, but do not remember exactly what it was. Anyway it is covered by case above.

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.

The question here is that if taskCount is not provided, and an autoscaler is provided yet disabled, what should we use for the initial taskCount? This only matters on the very first submission of a supervisor, since if there's an existing supervisor, we'll use its persisted taskCount (which will always be there).

Anyway, the old code used taskCountMin (ignoring taskCountStart if present). I thought that was strange: why use the autoscaler configs in a slightly different way if the autoscaler is not enabled? This PR changes it to use 1, on the grounds that if the autoscaler is submitted in a disabled state then its configuration should not apply.

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.

Agree, thanks.

@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.

I have reviewed the code for correctness, edge cases, concurrency, and integration risks; no issues found.


This is an automated review by Codex GPT-5

@gianm
gianm merged commit 0920a93 into apache:master May 6, 2026
63 of 66 checks passed
@gianm
gianm deleted the fix-task-count-persistence branch May 6, 2026 16:49
@github-actions github-actions Bot added this to the 38.0.0 milestone May 6, 2026
317brian pushed a commit to 317brian/druid that referenced this pull request May 11, 2026
…9417)

PR apache#18745 included a discussion of desired behavior of taskCount,
taskCountStart, and taskCountMin, but this has not been fully
implemented. This patch updates logic to align with the intent.
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.

4 participants