Skip to content

Fix flaky 05045_create_token when a token deadline falls into the hour repeated at the end of DST - #127762

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05045-create-token-dst
Oct 25, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-05045-create-token-dst

Conversation

@groeneai

@groeneai groeneai commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #116957

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

05045_create_token reads the deadline returned by CREATE TOKEN back from text: valid_until is a DateTime64(0) without a time zone, printed as local time with no offset, and the test parses it with toDateTime64('<text>', 0) to compare it with now() and with system.users. When DST ends, one local hour happens twice, and its text parses back to the first occurrence. The CI server zone is Europe/Amsterdam, which left CEST at 2026-10-25 01:00 UTC. Every run that created a token between about 00:30 and 01:59 UTC got a deadline in the second 02:xx hour, read it back one hour early, and printed 0 for the 30-minute and/or the 60-second check. It failed 3/3 on 7 unrelated PRs in the jobs that run without random settings, for example PR 127586 and PR 121154.

The two deadlines compared with now() are now requested with date_time_output_format = 'unix_timestamp' and passed to toDateTime64 as a number, so the checks mean the same in every zone at any time. The .reference does not change. The fixed deadlines (2077, 0, year 9999) still go through text, because their display is what those lines check.

Validation on a Europe/Amsterdam server:

  • a TTL ending at 2027-10-31 01:15 UTC (the second 02:15): the old statements read the deadline 3600 s early and countEqual is 0; the new statements and the first-occurrence control are exact;
  • inside the real repeated hour (2026-10-25 01:29 UTC): old test FAIL on all three lines, new test OK;
  • 50 randomized runs in that hour: old 9 FAIL, exactly the 9 runs that drew Europe/Amsterdam; new 50/50 OK.

Workflow [PR]
Sync PR [sync-upstream/pr/127762]

Version info

  • Merged into: 26.11.1.758-master (included in 26.11 and later)

…our repeated at the end of DST

`CREATE TOKEN` returns `valid_until` as a `DateTime64(0)` without a time
zone, so it is printed as local wall-clock text with no offset. The test
parsed that text back with `toDateTime64('<text>', 0)` to compare it with
`now()` and with `system.users`. In the hour that repeats when DST ends the
text is ambiguous and parses back to the first occurrence, one hour early,
so the 30-minute check, the stored-deadline check and the 60-second check
printed 0.

The CI server zone is `Europe/Amsterdam` (`TZ` in the test-base image),
which left CEST at 2026-10-25 01:00 UTC. The test failed 3/3 on 7 unrelated
PRs that night, in the jobs that run without random settings and whenever
the runner drew `session_timezone = 'Europe/Amsterdam'`.

Read the two now-relative deadlines back as a Unix timestamp
(`date_time_output_format = 'unix_timestamp'`), which names one instant in
every zone. The fixed deadlines (2077, 0, year 9999) stay text on purpose:
their display is what those lines assert.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

Own cold review + Gate B (codex) on 0a18d07e348: 0 blockers, 0 majors, 3 nits.

Finding Verdict
💡 PR description presented a local measurement (failures on session_timezone = 'Europe/Amsterdam' draws) as a CI observation AGREE, fixed in the description
💡 The new test comment writes now() without inline code AGREE, noted, not blocking (cosmetic)
💡 The commit message does not repeat the two CI report links AGREE, noted, not blocking (both links are in the description)

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On a Europe/Amsterdam server a TTL ending at 2027-10-31 01:15 UTC (the second local 02:15) is read back 3600 s early and countEqual is 0; a TTL ending at 00:15 UTC (the first 02:15) is exact.
b Root cause explained? valid_until is printed as local text with no offset; in the repeated DST hour toDateTime64('<text>', 0) picks the first occurrence.
c Fix matches root cause? Yes. The now-relative deadlines are read back as a Unix timestamp (date_time_output_format = 'unix_timestamp'). No tag, no widened bound.
d Test intent preserved / new tests added? Yes. Same assertions and bounds, .reference unchanged; with the setting removed the test fails with a syntax error, never silently.
e Both directions demonstrated? Yes. Inside the real repeated hour (2026-10-25 01:29 UTC): old FAIL on all three lines, new OK; 50 randomized runs: old 9 FAIL (the Europe/Amsterdam draws), new 50/50 OK.
f Fix is general across code paths? Yes. All three now-relative round trips in the file are fixed; the fixed-instant deadlines stay text because their display is asserted.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). All six randomized session_timezone values pass.
h Backward compatible? (maintainer-approved exception only) N/A (test-only).
i Invariants and contracts preserved? Yes. Deadline is about now + TTL and the reported deadline equals the stored one, at every wall-clock time.

Session id: cron:clickhouse-impl-slot-4:20261025-012700

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @kcmannem, could you review this and add the can be tested label so CI runs? The test parsed the CREATE TOKEN deadline back from local-time text, which is ambiguous in the hour repeated when DST ends (Europe/Amsterdam on 2026-10-25), so it now reads the two now-relative deadlines as Unix timestamps; test-only, .reference unchanged.

@clickhouse-gh

clickhouse-gh Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0a18d07]

Summary: ✅


AI Review

Summary

PR #127762 fixes DST-dependent failures in 05045_create_token by reading relative token deadlines as Unix timestamps and converting them numerically. The existing TTL bounds, stored-deadline assertion, and reference output are preserved. No actionable findings in commit 0a18d07e34827ac16db2050d873e0da148680d03.

Missing context / blind spots
  • ⚠️ Available CI reports do not show execution of 05045_create_token, which is tagged no-fasttest. The PR describes successful deterministic DST reproductions and randomized runs; a stateless CI run of this test would independently confirm those results.
Final Verdict

Status: ✅ Approve

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 25, 2026
Merged via the queue into ClickHouse:master with commit f50ab22 Oct 25, 2026
526 of 528 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 25, 2026
@clickhouse-gh clickhouse-gh Bot added comp-authentication Identity verification: users, credentials, auth methods, external auth providers. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-authentication Identity verification: users, credentials, auth methods, external auth providers. pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants