You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "cryptoe (via GitHub)" <gi...@apache.org> on 2026/09/28 19:58:36 UTC
[PR] `unannouncePropagationDelay` should be ignored for tasks which don't support querying (druid)
cryptoe opened a new pull request, #20444:
URL: https://github.com/apache/druid/pull/20444
### Description
`druid.server.http.unannouncePropagationDelay` makes a server sleep before Jetty stops, so that brokers stop routing
queries to it first. Task runners pass runtime properties down to every peon, so if an operator sets this delay
(for example `PT30S`) so that realtime tasks don't disappear while a query is being routed to them, **every** task
inherits it. Batch, compaction, MSQ and other tasks that never serve queries then sleep for the full delay before
exiting, which slows down task turnover and wastes task slots.
This PR makes peons ignore the delay when the task they are running does not serve queries.
#### Release note
Peons running tasks that do not serve queries (for example batch, compaction and MSQ tasks) now ignore
`druid.server.http.unannouncePropagationDelay` and shut down without waiting. Realtime streaming tasks still honor
the delay.
This PR has:
- [x] been self-reviewed.
- [x] 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.)
- [x] added documentation for new or modified features or behaviors.
- [x] a release note entry in the PR description.
--
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] minor: `unannouncePropagationDelay` should be ignored for tasks which don't support querying (druid)
Posted by "cryptoe (via GitHub)" <gi...@apache.org>.
cryptoe merged PR #20444:
URL: https://github.com/apache/druid/pull/20444
--
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] minor: `unannouncePropagationDelay` should be ignored for tasks which don't support querying (druid)
Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm commented on code in PR #20444:
URL: https://github.com/apache/druid/pull/20444#discussion_r4126719942
##########
services/src/main/java/org/apache/druid/guice/PeonServerModule.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.guice;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.inject.Binder;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import org.apache.druid.guice.annotations.Self;
+import org.apache.druid.indexing.common.task.Task;
+import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.java.util.common.lifecycle.Lifecycle;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.query.FakeQuery;
+import org.apache.druid.query.TableDataSource;
+import org.apache.druid.query.spec.MultipleIntervalSegmentSpec;
+import org.apache.druid.server.DruidNode;
+import org.apache.druid.server.initialization.ServerConfig;
+import org.apache.druid.server.initialization.TLSServerConfig;
+import org.apache.druid.server.initialization.jetty.JettyServerModule;
+import org.apache.druid.server.security.TLSCertificateChecker;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.joda.time.Period;
+
+import java.util.Collections;
+
+public class PeonServerModule implements Module
+{
+ private static final Logger log = new Logger(PeonServerModule.class);
+
+ /**
+ * Used for the {@link FakeQuery} probe when the task has no datasource, since {@link TableDataSource} requires one.
+ */
+ private static final String PLACEHOLDER_DATASOURCE = "__fake";
+
+ @Override
+ public void configure(Binder binder)
+ {
+ }
+
+ @Provides
+ @LazySingleton
+ public Server getServer(
+ final Injector injector,
+ final Lifecycle lifecycle,
+ @Self final DruidNode node,
+ final ServerConfig config,
+ final TLSServerConfig tlsServerConfig,
+ final Task task
+ )
+ {
+ return JettyServerModule.makeAndInitializeServer(
+ injector,
+ lifecycle,
+ node,
+ adjustServerConfig(config, task),
+ tlsServerConfig,
+ injector.getExistingBinding(Key.get(SslContextFactory.Server.class)),
+ injector.getInstance(TLSCertificateChecker.class)
+ );
+ }
+
+ @VisibleForTesting
+ static ServerConfig adjustServerConfig(final ServerConfig config, final Task task)
+ {
+ if (Period.ZERO.equals(config.getUnannouncePropagationDelay()) || isQueryable(task)) {
+ return config;
+ }
+
+ log.info(
+ "Ignoring unannouncePropagationDelay[%s] since task[%s] of type[%s] does not serve queries.",
+ config.getUnannouncePropagationDelay(),
+ task.getId(),
+ task.getType()
+ );
+ return config.withUnannouncePropagationDelay(Period.ZERO);
+ }
+
+ /**
+ * Whether the task answers queries over its datasource. {@link Task#getQueryRunner} returns null for tasks that
+ * do not, so probe it with a {@link FakeQuery} on the task's datasource.
+ */
+ private static boolean isQueryable(final Task task)
+ {
+ final String dataSource = task.getDataSource() == null ? PLACEHOLDER_DATASOURCE : task.getDataSource();
+ final FakeQuery query = new FakeQuery(
Review Comment:
How about using a simple, yet real, query type like `DataSourceMetadataQuery`? This is to avoid having to create `FakeQuery`.
--
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] minor: `unannouncePropagationDelay` should be ignored for tasks which don't support querying (druid)
Posted by "cryptoe (via GitHub)" <gi...@apache.org>.
cryptoe commented on code in PR #20444:
URL: https://github.com/apache/druid/pull/20444#discussion_r4127255085
##########
services/src/main/java/org/apache/druid/guice/PeonServerModule.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.guice;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.inject.Binder;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.Provides;
+import org.apache.druid.guice.annotations.Self;
+import org.apache.druid.indexing.common.task.Task;
+import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.java.util.common.lifecycle.Lifecycle;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.query.FakeQuery;
+import org.apache.druid.query.TableDataSource;
+import org.apache.druid.query.spec.MultipleIntervalSegmentSpec;
+import org.apache.druid.server.DruidNode;
+import org.apache.druid.server.initialization.ServerConfig;
+import org.apache.druid.server.initialization.TLSServerConfig;
+import org.apache.druid.server.initialization.jetty.JettyServerModule;
+import org.apache.druid.server.security.TLSCertificateChecker;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.joda.time.Period;
+
+import java.util.Collections;
+
+public class PeonServerModule implements Module
+{
+ private static final Logger log = new Logger(PeonServerModule.class);
+
+ /**
+ * Used for the {@link FakeQuery} probe when the task has no datasource, since {@link TableDataSource} requires one.
+ */
+ private static final String PLACEHOLDER_DATASOURCE = "__fake";
+
+ @Override
+ public void configure(Binder binder)
+ {
+ }
+
+ @Provides
+ @LazySingleton
+ public Server getServer(
+ final Injector injector,
+ final Lifecycle lifecycle,
+ @Self final DruidNode node,
+ final ServerConfig config,
+ final TLSServerConfig tlsServerConfig,
+ final Task task
+ )
+ {
+ return JettyServerModule.makeAndInitializeServer(
+ injector,
+ lifecycle,
+ node,
+ adjustServerConfig(config, task),
+ tlsServerConfig,
+ injector.getExistingBinding(Key.get(SslContextFactory.Server.class)),
+ injector.getInstance(TLSCertificateChecker.class)
+ );
+ }
+
+ @VisibleForTesting
+ static ServerConfig adjustServerConfig(final ServerConfig config, final Task task)
+ {
+ if (Period.ZERO.equals(config.getUnannouncePropagationDelay()) || isQueryable(task)) {
+ return config;
+ }
+
+ log.info(
+ "Ignoring unannouncePropagationDelay[%s] since task[%s] of type[%s] does not serve queries.",
+ config.getUnannouncePropagationDelay(),
+ task.getId(),
+ task.getType()
+ );
+ return config.withUnannouncePropagationDelay(Period.ZERO);
+ }
+
+ /**
+ * Whether the task answers queries over its datasource. {@link Task#getQueryRunner} returns null for tasks that
+ * do not, so probe it with a {@link FakeQuery} on the task's datasource.
+ */
+ private static boolean isQueryable(final Task task)
+ {
+ final String dataSource = task.getDataSource() == null ? PLACEHOLDER_DATASOURCE : task.getDataSource();
+ final FakeQuery query = new FakeQuery(
Review Comment:
Probably better.
--
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