Skip to content

Add dynamic default query context#19144

Open
jtuglu1 wants to merge 3 commits intoapache:masterfrom
jtuglu1:dynamic-query-context
Open

Add dynamic default query context#19144
jtuglu1 wants to merge 3 commits intoapache:masterfrom
jtuglu1:dynamic-query-context

Conversation

@jtuglu1
Copy link
Contributor

@jtuglu1 jtuglu1 commented Mar 12, 2026

Description

Query context can currently be supplied via 3 places:

  1. The per-query context override field.
  2. The static node configuration provided at Druid process boot.
  3. The query context defaults in the code itself.

Neither of these two options are helpful for tuning "default" query context values as with 1) you need to constantly re-deploy as you tune and 2) you rely on the user to set these values (not good).

This introduces a fourth query context resolution layer in the broker dynamic config. Resolution order is now:

  1. The per-query context
  2. The broker dynamic config value
  3. The static node configuration value
  4. The default values in the code itself

Release note

Add dynamic default query context to brokers. Allows operators to quickly tune the default setting for query context values without requiring a re-deployment or forcing upstream clients to update their queries.


This PR has:

  • been self-reviewed.
  • 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
  • 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 is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@jtuglu1 jtuglu1 changed the title Add dynamic query context Add dynamic default query context Mar 12, 2026
@jtuglu1 jtuglu1 force-pushed the dynamic-query-context branch from c8dd219 to 93f429c Compare March 12, 2026 18:34
@jtuglu1 jtuglu1 marked this pull request as ready for review March 12, 2026 19:12
@jtuglu1 jtuglu1 added this to the 37.0.0 milestone Mar 12, 2026
@jtuglu1 jtuglu1 force-pushed the dynamic-query-context branch from 93f429c to ce89abb Compare March 12, 2026 23:35
@jtuglu1 jtuglu1 force-pushed the dynamic-query-context branch from ce89abb to 56a3cce Compare March 13, 2026 03:19
Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

Useful idea.


Broker dynamic configuration is managed through the Coordinator but consumed by Brokers.
These settings control broker behavior such as query blocking rules.
These settings control broker behavior such as query blocking rules and default query context values.
Copy link
Contributor

Choose a reason for hiding this comment

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

For the blocking we have this warning:

Note: Query blocking is best-effort. Queries may not be blocked in certain cases, such as when a Broker has recently started and hasn't received the config yet, or if the Broker cannot contact the Coordinator. Brokers poll the configuration periodically (default every 1 minute) and also receive push updates from the Coordinator for immediate propagation.

I think we need a similar warning for context. Maybe put this warning at the top of the "Broker dynamic configuration" section and make clear it applies to everything in here. I say this because in case default query context properties are "important" (i.e. operators really want them to always be set) they may be surprised that they are in fact not necessarily always going to be set.

This also makes me think at some point we might want to add a mode to make them actually guaranteed, i.e., block Broker startup until first sync of dynamic config. Doesn't have to be done in this PR.

Copy link
Contributor Author

@jtuglu1 jtuglu1 Mar 13, 2026

Choose a reason for hiding this comment

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

Sure. I think we can make this an opt-in config on the broker, but I think it should be a separate change.

@jtuglu1 jtuglu1 force-pushed the dynamic-query-context branch from 70ebff4 to a88ee7f Compare March 13, 2026 16:07
@jtuglu1 jtuglu1 requested a review from gianm March 14, 2026 03:00
@jtuglu1
Copy link
Contributor Author

jtuglu1 commented Mar 16, 2026

@gianm thoughts here?

@jtuglu1
Copy link
Contributor Author

jtuglu1 commented Mar 19, 2026

@gianm any thoughts here?

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.

2 participants