FrankChen021 opened a new pull request, #20647:
URL: https://github.com/apache/druid/pull/20647
### Description
#### Background
Since #20578 and #20579, every query context parameter is declared in
`QueryContextParameters`. Druid still silently ignores a parameter it doesn't
recognize, such as a misspelled `useCahce`, and only checks a parameter's value
when it first reads it, so an invalid value can go unnoticed or fail late.
#### New configuration and behavior
| Property | Default | Description |
|---|---|---|
| `druid.query.context.rejectUnknownParameters` | `false` | Whether to
reject query context parameters that Druid doesn't recognize. |
- The Broker checks the context that a query sets before running it: the
top-level context of native queries, and the context and `SET` statements of
SQL queries.
- Values of recognized parameters are always checked; an invalid one is
rejected with HTTP 400.
- Unrecognized parameters are rejected only if `rejectUnknownParameters`
is `true`, with suggestions for similar names: `Unknown query context parameter
[useCahce]. Did you mean [useCache]?`
- A query rejected this way fails before it's planned, so it isn't
request-logged or counted in `query/time` / `sqlQuery/time`, like a query that
can't be parsed.
- The connection properties of a JDBC connection, which are the query
context of every statement on it, are checked when the connection opens.
- Default contexts are checked the same way where they're configured: the
Broker fails to start if `druid.query.default.context.*` or
`druid.msq.dart.query.context.*` is invalid, and the Coordinator rejects a
Broker dynamic configuration update with an invalid `queryContext`.
- Data servers don't check contexts, so queries keep working during rolling
upgrades.
#### Upgrade note
JDBC connections now fail to open if a connection property, other than
`user` and `password`, sets a query context parameter to an invalid value; for
example `sqlTimeZone=Not/AZone`. Previously such a property failed only when a
query read it, or was ignored if no query did. This matches how databases such
as MySQL and PostgreSQL reject invalid session settings at connect. If
`druid.query.context.rejectUnknownParameters` is `true`, connections with a
connection property that Druid doesn't recognize also fail to open. Check the
connection properties of your JDBC clients before upgrading.
#### Release note
New property `druid.query.context.rejectUnknownParameters`, off by default:
when `true`, Druid rejects queries that set a query context parameter it
doesn't recognize, and suggests similar parameter names. Druid also checks the
values of query context parameters before running a query, and the default
query contexts where they're configured.
<hr>
This PR has:
- [x] been self-reviewed.
- [x] added documentation for new or modified features or behaviors.
- [x] a release note entry in the PR description.
- [x] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [x] added or updated unit tests to cover new code paths.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]