Skip to content

Fix flaky test 05055_format_schema_source_query_background_access when the session date is ahead of the server date - #127797

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05055-text-log-date-bound-timezone
Oct 28, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05055-text-log-date-bound-timezone

Conversation

@groeneai

@groeneai groeneai commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

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

05055_format_schema_source_query_background_access prints background flush refused: 0 instead of 1 when it runs between 22:00 and 23:00 UTC with session_timezone = Africa/Khartoum or Africa/Juba. On 2026-10-25 alone that happened 13 times, on 8 unrelated PRs and on master (master report); each time the runner's own diagnosis names --session_timezone as the culprit. No related open issue found.

The test rendered its start time with toString(now64(6)), i.e. in the session time zone, and bounded the system.text_log scan with event_date >= toDate('<start>'). text_log.event_date is computed in the server time zone (Europe/Amsterdam in CI). Since Amsterdam left DST on 2026-10-25, UTC+2 is one hour ahead of it, so during that hour the session date is the server date + 1 and every text_log part is pruned: the refusal row is logged but never matched. Unfixed, this recurs every day until 2027-03-28.

The start is now captured as toUnixTimestamp64Micro(now64(6)) and compared through fromUnixTimestamp64Micro, so the time bound no longer depends on the session time zone. The partition bound is the usual event_date >= yesterday(), which stays at or before the server date while the session zone is less than a day ahead of the server zone (CI draws session_timezone from UTC-7 and UTC+2 zones or the local one). Test-only; the reference is unchanged.

Validation, master debug binary, server TZ=Etc/GMT+12 with client session_timezone=Etc/GMT-12 (session date always one day ahead): the unfixed test fails 3/3 with the CI diff and passes 3/3 without the client override; the fixed test passes 20/20. The fixed test also passes 5/5 with the reverse pair, 5/5 with Europe/Amsterdam + Africa/Khartoum, and 50/50 fully randomized.


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

Version info

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

…ependent

The test rendered its start instant in the randomized session time zone and
bounded the text_log scan with `event_date >= toDate('<start>')`, while
`text_log.event_date` is computed in the server time zone. When the session
date runs ahead of the server date (CI: Africa/Khartoum or Africa/Juba vs
Europe/Amsterdam, 22:00-23:00 UTC since Amsterdam left DST on 2026-10-25),
every text_log part was pruned and the refusal was never found.

Capture the start as a Unix timestamp in microseconds, compare
`event_time_microseconds` against it directly, and bound the partition scan
with `event_date >= yesterday()`.

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

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

Pre-publication review by an independent model (engine: codex; 1 finding over 2 Gate B runs on the same tree; second run after a PR-text correction: 0 findings).

# Sev Finding Verdict Evidence / action
1 ⚠️ event_date >= yesterday() still uses the session time zone and can exclude the server's date when the session zone is a day or more ahead (UTC+14 session, UTC-12 server) DISAGREE Unreachable in the harness: tests/clickhouse-test draws session_timezone from UTC-7 and UTC+2 zones or the local zone, and the server zone is at least UTC-11, so the lead is at most 13 h and yesterday() stays at or before the server date. The description's over-broad wording was corrected instead.
2 💡 Failure count in the description was stale AGREE, fixed Re-measured in CIDB before publication

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261025-231700

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Server with TZ=Etc/GMT+12, client --client-option session_timezone=Etc/GMT-12 (session date is always the server date + 1): the unfixed test fails 3/3 with -background flush refused: 1 / +background flush refused: 0, the CI diff.
b Root cause explained? The start time was rendered in the session time zone and the system.text_log scan was bounded with event_date >= toDate('<start>'), while event_date is in the server time zone. When the session date is ahead (CI: Africa/Khartoum/Africa/Juba vs Europe/Amsterdam, 22:00-23:00 UTC since 2026-10-25), every part is pruned and the refusal row is never matched.
c Fix matches root cause? Yes. Both bounds are made time zone free: an integer microsecond start compared through fromUnixTimestamp64Micro, and event_date >= yesterday(). No setting pinned, no tag added; session_timezone stays randomized.
d Test intent preserved / new tests added? Yes. The reference is unchanged: the test still requires the background refusal, the row left in the buffer, and the foreground insert. Test-only fix, no new test.
e Both directions demonstrated? Yes. Same server and flags: unfixed FAIL 3/3, fixed PASS 20/20; control without the client override: unfixed PASS 3/3.
f Fix is general across code paths? Both time bounds of the only time-filtered query are fixed. Other tests with the same event_date >= toDate(<start>) shape are not failing and are left alone.
g Fix generalizes across inputs (params/datatypes/wrappers)? Session date ahead (20/20), behind (5/5), CI's pair Europe/Amsterdam + Africa/Khartoum (5/5), and 50/50 fully randomized runs covering all six session_timezone choices.
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? Yes. Only rows logged after this run's start still count, now without a time zone round trip; the event_date bound keeps the partition pruning.

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

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @al13n321, could you review this and add the can be tested label so CI runs? The test bounded its system.text_log scan with event_date >= toDate(<start rendered in the session time zone>), but event_date is in the server time zone, so with Africa/Khartoum sessions against the Europe/Amsterdam server it pruned every part between 22:00 and 23:00 UTC; the start is now an integer microsecond timestamp and the date bound is yesterday().

@clickhouse-gh

clickhouse-gh Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [39c6397]

Summary: ✅


AI Review

Summary

The PR fixes time-zone-dependent failures in 05055_format_schema_source_query_background_access by retaining the start instant as Unix microseconds and using yesterday for the system.text_log.event_date bound. No actionable findings. The documented deterministic before/after runs support the fix, and the original assertions remain intact.

Missing context / blind spots
  • ⚠️ CI for head 39c63970c9871d4f667776d5a714c2dff5557437 is still in progress. The targeted stateless report has no results yet; runtime evidence comes from the PR's documented validation rather than an independent local rerun.
Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 25, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 27, 2026
@PedroTadim

Copy link
Copy Markdown
Member

Backporting to fix CI

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 30, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 30, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 30, 2026
Backport #127797 to 26.10: Fix flaky test `05055_format_schema_source_query_background_access` when the session date is ahead of the server date
clickhouse-gh Bot added a commit that referenced this pull request Oct 30, 2026
Backport #127797 to 26.9: Fix flaky test `05055_format_schema_source_query_background_access` when the session date is ahead of the server date
clickhouse-gh Bot added a commit that referenced this pull request Oct 30, 2026
Backport #127797 to 26.8: Fix flaky test `05055_format_schema_source_query_background_access` when the session date is ahead of the server date
PedroTadim added a commit that referenced this pull request Oct 30, 2026
Backport #127797 to 26.3: Fix flaky test `05055_format_schema_source_query_background_access` when the session date is ahead of the server date
rorylshanks added a commit to rorylshanks/ClickHouse that referenced this pull request Nov 3, 2026
No conflicts. Picks up the fix for the flaky
`05055_format_schema_source_query_background_access` test
(ClickHouse#127797).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01E5v7QTSR65LdYnQEv9HJVu
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…query_background_access` when the session date is ahead of the server date
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…query_background_access` when the session date is ahead of the server date
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…query_background_access` when the session date is ahead of the server date
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…_query_background_access` when the session date is ahead of the server date
@clickhouse-gh clickhouse-gh Bot added comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). 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

blocker This issue / pr blocks a new release can be tested Allows running workflows for external contributors comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants