Repository navigation
Apply the server's TimezoneUpdate before clickhouse-client parses the data of input() and RETURNING - #131177
Conversation
…data The server sends `TimezoneUpdate` right after the input-schema `Data` of the `input` initializer (also used by `INSERT ... RETURNING` with client data), and the protocol defines it as applying to the rows the client is about to send. `receiveSampleBlock` returned at the schema, so the update was read by `receiveLogsAndProfileEvents` only after `sendDataFromPipe` had started the parsing pipeline, and `onTimezoneUpdate` wrote `session_timezone` of `client_context` while the pipeline thread read it in `DateLUT::instance`: a data race, and, when the server's `session_timezone` differs from the client's (a profile `session_timezone` with `apply_settings_from_server = 0`), the first rows of the INSERT parsed in the client's time zone. For an INSERT whose data the server reads through `input` (an `input` SELECT or `RETURNING`), over a remote connection to a server new enough to send the update, `receiveSampleBlock` now reads on to the `TimezoneUpdate`, so it is applied on the main thread before any parsing thread exists. A server that sends it before the schema is handled by the existing case; `LocalConnection` sends no update and is excluded. Reported by La Casa Del Dolor (amd_tsan): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130445&sha=f5439ede34c44107959c68017dfe1f3caedafbf0&name_0=PR&name_1=La%20Casa%20Del%20Dolor%20%28amd_tsan%29 ClickHouse#130445 https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=4951f241cfaff37833813a18a5544f0ab312ca64&name_0=MasterCI&name_1=La%20Casa%20Del%20Dolor%20%28amd_tsan%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings in both rounds) plus my own cold review.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261113-013900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261113-012100 |
|
Workflow [PR], commit [6e5bd61] Summary: ✅
AI ReviewSummaryReviewed #131177 at Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units21 translation units recompiled, 128 s compile time in total, 21 of them have a recent master baseline. |
74c7bf9
Related: #130445
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
clickhouse-clientparsing the data ofINSERT ... SELECT ... FROM input(...)partly or entirely in its own time zone instead of thesession_timezonethe server uses for the query (for example one set in a user profile withapply_settings_from_server = 0). This also fixes a data race onsession_timezonein the client.Description
On 26.10,
INSERT INTO t SELECT * FROM input('d DateTime') FORMAT Valuessent byclickhouse-clientas a user whose profile setssession_timezone(withapply_settings_from_server = 0) evaluates the firsttoDateTime(...)rows in the client's time zone and the rest in the profile's (17-24 of 500 rows wrong on official 26.10.2.103 and 26.3.60.2). PlainDateTimetext values were parsed in the client's time zone in every row, now in the profile's.The server sends
TimezoneUpdateright after the input-schemaData(also forINSERT ... RETURNINGwith client data), and the protocol defines it as applying to the rows the client sends.receiveSampleBlockreturned at the schema, so the update was read aftersendDataFromPipestarted the parsing pipeline, andonTimezoneUpdatewrotesession_timezoneofclient_contextwhile the pipeline thread read it inDateLUT::instance: the data race La Casa Del Dolor (amd_tsan) reports sinceRETURNINGis fuzzed (master, #130445).For an INSERT whose data the server reads through
input(input()orRETURNING), over a remote connection to a server that sends it,receiveSampleBlocknow reads on to theTimezoneUpdate, so it is applied before any parsing thread exists. Servers that send it first (#118415) still work; older servers andclickhouse-localare unchanged.The new test fails 20/20 on master and passes 100/100 with the fix; against 26.3, 26.10 and master servers the fixed client parses every row in the server's zone, with no added wait.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131177]
Version info
26.11.1.2165-master(included in26.11and later)