You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "gianm (via GitHub)" <gi...@apache.org> on 2026/05/06 07:40:50 UTC
[PR] fix: Precedence of taskCount and taskCountStart. (druid)
gianm opened a new pull request, #19417:
URL: https://github.com/apache/druid/pull/19417
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.
--
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] fix: Precedence of taskCount, taskCountStart, taskCountMin. (druid)
Posted by "Fly-Style (via GitHub)" <gi...@apache.org>.
Fly-Style commented on code in PR #19417:
URL: https://github.com/apache/druid/pull/19417#discussion_r3194062626
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorIOConfig.java:
##########
@@ -90,16 +99,19 @@ public SeekableStreamSupervisorIOConfig(
this.autoScalerConfig = autoScalerConfig;
boolean isAutoScalerAvailable = autoScalerConfig != null;
this.autoScalerEnabled = isAutoScalerAvailable && autoScalerConfig.getEnableTaskAutoScaler();
- if (autoScalerEnabled) {
- // Priority: taskCountStart > taskCount > taskCountMin
+ this.taskCountExplicit = taskCount != null;
+ if (taskCount != null) {
+ // Always retain taskCount when deserializing. Note: taskCountStart takes precedence over taskCount
+ // in SeekableStreamSupervisorSpec#merge, to ensure that when a supervisor is explicitly POSTed, taskCount
+ // is reset to taskCountStart.
+ this.taskCount = taskCount;
+ } else if (autoScalerEnabled) {
this.taskCount = Configs.valueOrDefault(
autoScalerConfig.getTaskCountStart(),
- Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin())
+ autoScalerConfig.getTaskCountMin()
);
- } else if (isAutoScalerAvailable) {
- this.taskCount = Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin());
} else {
- this.taskCount = Configs.valueOrDefault(taskCount, 1);
+ this.taskCount = 1;
Review Comment:
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 led to some inaccurate behaviour some time ago, but do not remember exactly what it was.
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorIOConfig.java:
##########
@@ -90,16 +99,19 @@ public SeekableStreamSupervisorIOConfig(
this.autoScalerConfig = autoScalerConfig;
boolean isAutoScalerAvailable = autoScalerConfig != null;
this.autoScalerEnabled = isAutoScalerAvailable && autoScalerConfig.getEnableTaskAutoScaler();
- if (autoScalerEnabled) {
- // Priority: taskCountStart > taskCount > taskCountMin
+ this.taskCountExplicit = taskCount != null;
+ if (taskCount != null) {
Review Comment:
nit: may use `this.taskCountExplicit` for condition
--
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] fix: Precedence of taskCount, taskCountStart, taskCountMin. (druid)
Posted by "Fly-Style (via GitHub)" <gi...@apache.org>.
Fly-Style commented on code in PR #19417:
URL: https://github.com/apache/druid/pull/19417#discussion_r3194477901
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorIOConfig.java:
##########
@@ -90,16 +99,19 @@ public SeekableStreamSupervisorIOConfig(
this.autoScalerConfig = autoScalerConfig;
boolean isAutoScalerAvailable = autoScalerConfig != null;
this.autoScalerEnabled = isAutoScalerAvailable && autoScalerConfig.getEnableTaskAutoScaler();
- if (autoScalerEnabled) {
- // Priority: taskCountStart > taskCount > taskCountMin
+ this.taskCountExplicit = taskCount != null;
+ if (taskCount != null) {
+ // Always retain taskCount when deserializing. Note: taskCountStart takes precedence over taskCount
+ // in SeekableStreamSupervisorSpec#merge, to ensure that when a supervisor is explicitly POSTed, taskCount
+ // is reset to taskCountStart.
+ this.taskCount = taskCount;
+ } else if (autoScalerEnabled) {
this.taskCount = Configs.valueOrDefault(
autoScalerConfig.getTaskCountStart(),
- Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin())
+ autoScalerConfig.getTaskCountMin()
);
- } else if (isAutoScalerAvailable) {
- this.taskCount = Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin());
} else {
- this.taskCount = Configs.valueOrDefault(taskCount, 1);
+ this.taskCount = 1;
Review Comment:
Agree, 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] fix: Precedence of taskCount, taskCountStart, taskCountMin. (druid)
Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm merged PR #19417:
URL: https://github.com/apache/druid/pull/19417
--
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] fix: Precedence of taskCount, taskCountStart, taskCountMin. (druid)
Posted by "Fly-Style (via GitHub)" <gi...@apache.org>.
Fly-Style commented on code in PR #19417:
URL: https://github.com/apache/druid/pull/19417#discussion_r3194062626
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorIOConfig.java:
##########
@@ -90,16 +99,19 @@ public SeekableStreamSupervisorIOConfig(
this.autoScalerConfig = autoScalerConfig;
boolean isAutoScalerAvailable = autoScalerConfig != null;
this.autoScalerEnabled = isAutoScalerAvailable && autoScalerConfig.getEnableTaskAutoScaler();
- if (autoScalerEnabled) {
- // Priority: taskCountStart > taskCount > taskCountMin
+ this.taskCountExplicit = taskCount != null;
+ if (taskCount != null) {
+ // Always retain taskCount when deserializing. Note: taskCountStart takes precedence over taskCount
+ // in SeekableStreamSupervisorSpec#merge, to ensure that when a supervisor is explicitly POSTed, taskCount
+ // is reset to taskCountStart.
+ this.taskCount = taskCount;
+ } else if (autoScalerEnabled) {
this.taskCount = Configs.valueOrDefault(
autoScalerConfig.getTaskCountStart(),
- Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin())
+ autoScalerConfig.getTaskCountMin()
);
- } else if (isAutoScalerAvailable) {
- this.taskCount = Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin());
} else {
- this.taskCount = Configs.valueOrDefault(taskCount, 1);
+ this.taskCount = 1;
Review Comment:
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.
--
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] fix: Precedence of taskCount, taskCountStart, taskCountMin. (druid)
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #19417:
URL: https://github.com/apache/druid/pull/19417#discussion_r3193932715
##########
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorSpecTest.java:
##########
@@ -422,6 +425,46 @@
Assert.assertFalse(runningSpec.isSuspended());
}
+ @Test
+ public void testTaskCountSerdeRoundTrip() throws IOException
+ {
+ // A persisted taskCount must survive a serialize/deserialize round-trip even when
+ // autoScalerConfig.taskCountStart is set.
+ final CostBasedAutoScalerConfig autoScalerConfig =
+ CostBasedAutoScalerConfig.builder()
+ .enableTaskAutoScaler(true)
+ .taskCountMin(1)
+ .taskCountMax(100)
+ .taskCountStart(25)
+ .build();
+
+ final KafkaSupervisorSpec spec = new KafkaSupervisorSpecBuilder()
+ .withDataSchema(
+ schema -> schema
+ .withTimestamp(TimestampSpec.DEFAULT)
+ .withAggregators(new CountAggregatorFactory("rows"))
+ .withGranularity(new UniformGranularitySpec(Granularities.DAY, Granularities.NONE, null))
+ )
+ .withIoConfig(
+ ioConfig -> ioConfig
+ .withJsonInputFormat()
+ .withConsumerProperties(Map.of("bootstrap.servers", "localhost:9092"))
+ .withTaskCount(25)
+ .withAutoScalerConfig(autoScalerConfig)
+ .withLagAggregator(LagAggregator.DEFAULT)
+ )
+ .build("testDs", "metrics");
+
+ // Mutate taskCount the same way SeekableStreamSupervisor.changeTaskCountInIOConfig does,
+ // and verify that the mutation is picked up by serialization.
+ spec.getIoConfig().setTaskCount(50);
+ final byte[] payload = mapper.writeValueAsBytes(spec);
+ final KafkaSupervisorSpec roundTripped =
+ (KafkaSupervisorSpec) mapper.readValue(payload, SupervisorSpec.class);
+ Assert.assertEquals(50, roundTripped.getIoConfig().getTaskCount());
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [KafkaSupervisorSpec.getIoConfig](1) should be avoided because it has been deprecated.
[Show more details](https://github.com/apache/druid/security/code-scanning/11178)
##########
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorSpecTest.java:
##########
@@ -422,6 +425,46 @@
Assert.assertFalse(runningSpec.isSuspended());
}
+ @Test
+ public void testTaskCountSerdeRoundTrip() throws IOException
+ {
+ // A persisted taskCount must survive a serialize/deserialize round-trip even when
+ // autoScalerConfig.taskCountStart is set.
+ final CostBasedAutoScalerConfig autoScalerConfig =
+ CostBasedAutoScalerConfig.builder()
+ .enableTaskAutoScaler(true)
+ .taskCountMin(1)
+ .taskCountMax(100)
+ .taskCountStart(25)
+ .build();
+
+ final KafkaSupervisorSpec spec = new KafkaSupervisorSpecBuilder()
+ .withDataSchema(
+ schema -> schema
+ .withTimestamp(TimestampSpec.DEFAULT)
+ .withAggregators(new CountAggregatorFactory("rows"))
+ .withGranularity(new UniformGranularitySpec(Granularities.DAY, Granularities.NONE, null))
+ )
+ .withIoConfig(
+ ioConfig -> ioConfig
+ .withJsonInputFormat()
+ .withConsumerProperties(Map.of("bootstrap.servers", "localhost:9092"))
+ .withTaskCount(25)
+ .withAutoScalerConfig(autoScalerConfig)
+ .withLagAggregator(LagAggregator.DEFAULT)
+ )
+ .build("testDs", "metrics");
+
+ // Mutate taskCount the same way SeekableStreamSupervisor.changeTaskCountInIOConfig does,
+ // and verify that the mutation is picked up by serialization.
+ spec.getIoConfig().setTaskCount(50);
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [KafkaSupervisorSpec.getIoConfig](1) should be avoided because it has been deprecated.
[Show more details](https://github.com/apache/druid/security/code-scanning/11177)
##########
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorSpecTest.java:
##########
@@ -422,6 +425,46 @@
Assert.assertFalse(runningSpec.isSuspended());
}
+ @Test
+ public void testTaskCountSerdeRoundTrip() throws IOException
+ {
+ // A persisted taskCount must survive a serialize/deserialize round-trip even when
+ // autoScalerConfig.taskCountStart is set.
+ final CostBasedAutoScalerConfig autoScalerConfig =
+ CostBasedAutoScalerConfig.builder()
+ .enableTaskAutoScaler(true)
+ .taskCountMin(1)
+ .taskCountMax(100)
+ .taskCountStart(25)
+ .build();
+
+ final KafkaSupervisorSpec spec = new KafkaSupervisorSpecBuilder()
+ .withDataSchema(
+ schema -> schema
+ .withTimestamp(TimestampSpec.DEFAULT)
+ .withAggregators(new CountAggregatorFactory("rows"))
+ .withGranularity(new UniformGranularitySpec(Granularities.DAY, Granularities.NONE, null))
+ )
+ .withIoConfig(
+ ioConfig -> ioConfig
+ .withJsonInputFormat()
+ .withConsumerProperties(Map.of("bootstrap.servers", "localhost:9092"))
+ .withTaskCount(25)
+ .withAutoScalerConfig(autoScalerConfig)
+ .withLagAggregator(LagAggregator.DEFAULT)
+ )
+ .build("testDs", "metrics");
+
+ // Mutate taskCount the same way SeekableStreamSupervisor.changeTaskCountInIOConfig does,
+ // and verify that the mutation is picked up by serialization.
+ spec.getIoConfig().setTaskCount(50);
+ final byte[] payload = mapper.writeValueAsBytes(spec);
+ final KafkaSupervisorSpec roundTripped =
+ (KafkaSupervisorSpec) mapper.readValue(payload, SupervisorSpec.class);
+ Assert.assertEquals(50, roundTripped.getIoConfig().getTaskCount());
+ Assert.assertTrue(roundTripped.getIoConfig().isTaskCountExplicit());
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [KafkaSupervisorSpec.getIoConfig](1) should be avoided because it has been deprecated.
[Show more details](https://github.com/apache/druid/security/code-scanning/11179)
--
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] fix: Precedence of taskCount, taskCountStart, taskCountMin. (druid)
Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm commented on code in PR #19417:
URL: https://github.com/apache/druid/pull/19417#discussion_r3194227810
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorIOConfig.java:
##########
@@ -90,16 +99,19 @@ public SeekableStreamSupervisorIOConfig(
this.autoScalerConfig = autoScalerConfig;
boolean isAutoScalerAvailable = autoScalerConfig != null;
this.autoScalerEnabled = isAutoScalerAvailable && autoScalerConfig.getEnableTaskAutoScaler();
- if (autoScalerEnabled) {
- // Priority: taskCountStart > taskCount > taskCountMin
+ this.taskCountExplicit = taskCount != null;
+ if (taskCount != null) {
+ // Always retain taskCount when deserializing. Note: taskCountStart takes precedence over taskCount
+ // in SeekableStreamSupervisorSpec#merge, to ensure that when a supervisor is explicitly POSTed, taskCount
+ // is reset to taskCountStart.
+ this.taskCount = taskCount;
+ } else if (autoScalerEnabled) {
this.taskCount = Configs.valueOrDefault(
autoScalerConfig.getTaskCountStart(),
- Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin())
+ autoScalerConfig.getTaskCountMin()
);
- } else if (isAutoScalerAvailable) {
- this.taskCount = Configs.valueOrDefault(taskCount, autoScalerConfig.getTaskCountMin());
} else {
- this.taskCount = Configs.valueOrDefault(taskCount, 1);
+ this.taskCount = 1;
Review Comment:
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.
--
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