Repository navigation
Apply only the client's setting changes to the query context in clickhouse-local - #125171
Conversation
…khouse-local` Since #114568, `LocalConnection::sendQuery` replaced the whole `Settings` of the query context with the client's copy. The client does not track `profile` (its `SET` bookkeeping skips it), so the settings a `SET profile` installed in the session were dropped for every following query: `currentProfiles` reported the profile, while `getSetting` showed the old values and a `readonly` profile did not block writes. Apply only `changes` of the client settings, like `TCPHandler`. Closes: #123916 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [00ac890] Summary: ✅
AI ReviewSummaryThis PR fixes the Final Verdict
|
| /// a `SET profile`, which the client does not track. | ||
| if (query_settings) | ||
| query_context->setSettings(*query_settings); | ||
| query_context->applySettingsChanges(query_settings->changes()); |
There was a problem hiding this comment.
This only fixes the execute-time overlay inside LocalConnection; clickhouse-local still parses the next statement with the stale client_context. After a successful SET profile, ClientBase still skips mirroring profile back into the client copy (src/Client/ClientBase.cpp:3172), and the single-query / multiquery parsers keep using client_context->getSettingsRef() before LocalConnection sees the query (src/Client/ClientBase.cpp:1606, src/Client/ClientBase.cpp:3363).
That means a profile that changes parse-time settings (dialect, enable_json_ast_dialect, max_parser_depth, etc.) still does not apply to the following queries in clickhouse-local even though it works over TCP. For example, a profile that sets enable_json_ast_dialect = 1, dialect = 'clickhouse_json' will still make the next JSON statement fail on the client side. Please refresh the local client_context from the session after a successful SET profile (or add a local equivalent of applySettingsFromServerIfNeeded) and cover one parse-time setting in the regression test.
There was a problem hiding this comment.
🕵 Not changing this in this PR. The parse-time part is not specific to clickhouse-local: clickhouse-client over TCP has the same limitation. The server sends its settings to the client only once, in the handshake (settings_from_server is filled in Connection::receiveHello, src/Client/Connection.cpp:722). After SET profile = 'p', ClientBase skips profile in the same way (src/Client/ClientBase.cpp:3172) and keeps parsing the next statements with its own client_context. So a profile that sets dialect / enable_json_ast_dialect / max_parser_depth does not reach the client-side parser over TCP either.
This PR restores what worked before #114568: the profile's settings apply when the following queries execute in clickhouse-local. That is what #123916 reports, and the test covers it, including readonly. Copying the session's settings back into client_context after SET profile is a separate change. It would also have to work for the TCP client, which does not get the profile's settings back after the handshake. And the client would then send the copied settings as changes with every query, which interacts badly with readonly profiles (see the note at src/Client/ClientBase.cpp:1278). That deserves its own PR.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline. |
…l` applying `SET profile` The last step of the test checked that the Kusto profile was in effect for the following queries by expecting `SELECT 1` to be rejected. Since ClickHouse#114568, `clickhouse-local` does not apply the settings of `SET profile` to later queries (ClickHouse#123916, fix pending in ClickHouse#125171), so `SELECT 1` succeeds and the test times out in Fast test. That step only guarded against the profile carrying nothing parser-shaping. Check this on the profile definition in `system.settings_profile_elements` instead, before `SET profile`, so the test holds both with and without the `clickhouse-local` fix. The continuation assertion itself is unchanged. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=101785&sha=9a99a51ef1b3008f00aff04d4b0a27d499db078d&name_0=PR&name_1=Fast%20test PR: ClickHouse#101785 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125171&sha=3ce4a5abbf148189390603fae2cb9a68764e4daa&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 ( |
|
The fix is already in progress: #123121 (mine, open). The missing table is the initiator's #123121 is waiting for review from @ novikd and @ devcrafter. |
In
clickhouse-local,SET profile = 'p'stopped applying the profile's settings to the queries that follow it. Since #114568,LocalConnection::sendQueryreplaces the wholeSettingsof the query context with the client's copy. The client never tracksprofile(itsSETbookkeeping skips it), so every query lost what the profile had installed in the session.currentProfilesstill reported the profile, butgetSettingshowed the old values,join_use_nullsfrom the profile was ignored, and areadonlyprofile did not block writes.The fix applies only the
changesof the client settings, the same wayTCPHandlerdoes. TheSET dialectpinning that #114568 needed still reaches the query context, because the pinneddialectis a change too.This also breaks the Fast test of #101785 (
04843_set_profile_continuation).Closes: #123916
Related: #114568
Related: #101785
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
SET profilehaving no effect on the following queries inclickhouse-local.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125171]
Version info
26.10.1.2215-master(included in26.10and later)