Skip to content

Add regression test for DateTime64 zero over remote() (issue #71288) - #104543

Merged
yariks5s merged 7 commits into
ClickHouse:masterfrom
groeneai:groeneai/test-71288-datetime64-remote-zero
Jul 9, 2026
Merged

yariks5s merged 7 commits into
ClickHouse:masterfrom
groeneai:groeneai/test-71288-datetime64-remote-zero

Conversation

@groeneai

@groeneai groeneai commented May 10, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Issue #71288
reported CANNOT_PARSE_DATETIME: while converting '0' to DateTime64(3)
when running

SELECT count()
FROM remote('127.0.0{1,2}', currentDatabase(), test)
WHERE r IN ( toDateTime64('1970-01-01 00:00:00.000', 3) )
SETTINGS allow_experimental_analyzer = 1;

against a Memory()-engine table whose DateTime64(3) column held the
epoch-zero value. The non-analyzer path returned the correct count; the
analyzer path threw CANNOT_PARSE_DATETIME while shipping the column to
the remote shard.

The bug was fixed around 24.9 — @den-crane verified on a fiddle
and asked us to land the missing regression test and close the issue.
This is probably a duplicate of #66773.

Change

Adds tests/queries/0_stateless/04218_distributed_remote_datetime64_zero_71288.sql
which runs the exact repro on both analyzer paths and asserts both
return 2 (one row per shard).

session_timezone = 'UTC' is pinned on each query so that CI's
randomized session timezone cannot cause the literal
'1970-01-01 00:00:00.000' to be interpreted in a non-UTC zone — that
mismatches the stored UTC epoch and would make the filter return 0
rows, which is unrelated to the bug under test. With the pin in place,
the test was confirmed stable: 50/50 passes locally under
--test-runs 50 with full settings randomization.

Closes #71288.

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):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.7.1.707 (included in 26.7 and later)

…se#71288)

Issue ClickHouse#71288 reported `CANNOT_PARSE_DATETIME: while converting '0' to
DateTime64(3)` when running

    SELECT count() FROM remote('127.0.0{1,2}', currentDatabase(), t)
    WHERE r IN (toDateTime64('1970-01-01 00:00:00.000', 3))

against a Memory()-engine table whose `DateTime64(3)` column held the
epoch-zero value, on the analyzer path. The fix landed around 24.9
(verified by @den-crane on https://fiddle.clickhouse.com/262f75d2-fcd2-4207-8894-712af5ea7bce
and confirmed on current master); this commit adds the missing
stateless regression test so the behavior cannot silently regress
again.

`session_timezone = 'UTC'` is pinned on each query so the DateTime
literal interpretation is stable under CI's randomized session
timezone — the bug being guarded against is independent of timezone.

Closes ClickHouse#71288.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (TASK.md Phase 4 step 9):

# Check Status
a Deterministic repro? YES — manual clickhouse-client with SET session_timezone='Africa/Juba' produces 0, 0; with 'UTC' produces 2, 2. Reproduces 100% of the time under the failing setting.
b Root cause explained? YES — the original bug (CANNOT_PARSE_DATETIME) is already fixed in 24.9 (verified by @den-crane on the linked fiddle and on current master). The test-stability issue that surfaced during development is timezone-only: the literal '1970-01-01 00:00:00.000' is parsed in the session timezone, while the column value 0 is stored as UTC epoch — under any non-UTC randomized timezone the converted UTC moments differ, so the filter matches no rows.
c Fix matches root cause? YES — session_timezone = 'UTC' pinned only on the two test queries is the minimal targeted change. Not a no-random-settings blanket, not a data-shape change.
d Test intent preserved? YES — the test still exercises both analyzer paths over remote('127.0.0{1,2}', ...) with a Memory() DateTime64(3) epoch-zero column, which is exactly what the original bug needed to trigger CANNOT_PARSE_DATETIME. Pinning the timezone does not weaken the regression check.
e Both directions demonstrated? "Without fix" is pre-24.9, verified by @den-crane on the linked fiddle. "With fix" is current master — locally --test-runs 50 is 50/50 passes with full settings randomization.
f Fix is general? N/A — this is a stateless regression test, not a code fix.

Session id: cron:clickhouse-ci-task-worker:20260510-214500.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @den-crane — this is the regression test you asked for in issue #71288. The test reproduces your fiddle on both analyzer paths; session_timezone = 'UTC' is pinned per query so CI's randomized session timezone cannot reinterpret the DateTime literal away from the stored UTC epoch (the bug being guarded against is timezone-independent). Verified locally with --test-runs 50 under full randomization. Closes #71288 on merge.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label May 10, 2026
CREATE TABLE test_71288 (r DateTime64(3)) ENGINE = Memory() AS SELECT 0;

SELECT count()
FROM remote('127.0.0{1,2}', currentDatabase(), test_71288)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a missing comma.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alexey-milovidov — I read this as "missing dot" since the comma count is correct for remote(addresses, db, table).

'127.0.0{1,2}' expands to hosts 127.0.01 and 127.0.02. ClickHouse's IP parser happens to resolve both to 127.0.0.1, so the test passed by accident — but the canonical form used in 20 other tests/queries/0_stateless files is '127.0.0.{1,2}' with the explicit dot before the brace.

Pushed 5c7df7cb24a to switch to the canonical form. Verified locally with --test-runs 50: 50/50 pass. Let me know if you meant something else and I'll address it.

@clickhouse-gh

clickhouse-gh Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c7e52c6]

Summary: ✅


AI Review

Summary

This PR adds a stateless regression test for issue #71288 by reproducing the remote() + DateTime64(3) epoch-zero case on both analyzer settings, pinning session_timezone so the literal stays deterministic under CI randomization, and asserting the filtered count stays 2. I reviewed the current head diff, the current file contents, the prior PR discussion, and every inline review thread, and I did not find any remaining correctness, coverage, or regression-test issues that warrant a new review comment.

Final Verdict

✅ Approve. No new findings on the current head.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 10, 2026
Address @alexey-milovidov inline review on PR ClickHouse#104543:
ClickHouse#104543 (comment)

The address literal '127.0.0{1,2}' (no dot before the brace expansion)
expands to hosts 127.0.01 and 127.0.02. ClickHouse's lenient IP parsing
still resolves both to 127.0.0.1, so the test passed by accident — but
the form is non-idiomatic: every other test in tests/queries/0_stateless
uses '127.0.0.{1,2}' (20 files) with the explicit dot before the brace.

This commit switches to the canonical form. Verified locally with
--test-runs 50: 50/50 pass on master HEAD.
@PedroTadim
PedroTadim enabled auto-merge May 11, 2026 08:11
@PedroTadim

Copy link
Copy Markdown
Member

@groeneai can you check the failing test? Maybe a separate PR to fix it is needed

@yariks5s yariks5s self-assigned this May 11, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

@PedroTadim — investigated; the failing test is unrelated to this PR and looks like a transient TSan+S3 timeout.

Failing check

Stateless tests (amd_tsan, s3 storage, sequential, 2/2) on commit 5c7df7cb24a — failing test is 03393_max_merge_delayed_streams_for_parallel_write (tagged long, uses metric_log with 1200+ columns + S3 storage + OPTIMIZE FINAL).

Failure mode

Reason: return code:  159
Error on processing query: Timeout exceeded while receiving data from server.
Waited for 300 seconds, timeout is 300 seconds.
(query: optimize table metric_log final;)

CI's own auto-rerun already passed

The praktika randomized-settings diagnosis ran in the same job and reports:

Step 1: Re-running with the same randomized settings (budget: 60s)...
  Runs: 1, Failed: 0, Passed: 1, Other: 0
Result: All reruns passed. The failure is not reproducible (likely a transient issue).

CIDB cross-PR data (last 30 days)

Metric Value
Total failures of 03393 8
Master failures 0
PR failures 8 across 2 unique PRs (#76867: 7 on 2026-04-27 batch, #104543: 1 today)

The April 27 cluster on #76867 hit 7 different checks within the same minute — a single CI-environment hiccup, not a per-test issue. Today's hit is identical pattern: 300s timeout on OPTIMIZE table metric_log FINAL under TSan+S3.

Our 04218 test (the one this PR adds)

Passes everywhere — 50/50 on each sanitizer flaky check (amd_asan_ubsan, amd_debug, amd_tsan, amd_msan), 10/10 on parallel-batch runs, 0 failures observed.

Recommendation

Re-run the failing check. Our regression test is stable and unrelated to 03393.

@PedroTadim

Copy link
Copy Markdown
Member

@groeneai can you create a separate PR to fix that test?

@groeneai

Copy link
Copy Markdown
Collaborator Author

@PedroTadim — separate PR opened: #104697 ("Stabilize 03393_max_merge_delayed_streams_for_parallel_write on TSan+S3").

Short version: reproduced locally on TSan+S3 — the OPTIMIZE FINAL itself takes ~77 seconds (~3600 small S3 files for a 1200-column metric_log), which is fine on master but can exceed the default 300s client receive_timeout under CI load. Fix follows the canonical pattern from 03015_optimize_final_rmt.sh: SETTINGS receive_timeout = 900 on each OPTIMIZE FINAL. Verified both directions (low timeout reproduces the exact CIDB error; 900s makes the full test pass 3/3 on TSan+S3 locally). No test semantics changed — same 1200 columns, same s3_no_cache policy, same merge settings.

Full Pre-PR validation gate is in the comment on #104697.

This PR (#104543) is otherwise AI-Review APPROVED — waiting on your acknowledgement on the missing-dot fix (5c7df7c) or on the CI re-run, whichever is more convenient.

pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Jun 2, 2026
The test creates a `metric_log`-shaped table (1200+ columns) on `s3_no_cache`
storage and runs `OPTIMIZE TABLE ... FINAL` twice. Under TSan (and any other
slow sanitizer) the merge is intrinsically slow: a local TSan+S3 reproduction
takes ~77-90s per `OPTIMIZE FINAL`. The default client `receive_timeout` is 300s,
which is fine on master but can be exceeded under CI load (parallel tests +
ThreadFuzzer + S3 throughput variability), producing a transient
`TIMEOUT_EXCEEDED` (code 159) of the form:

  Timeout exceeded while receiving data from server.
  Waited for 300 seconds, timeout is 300 seconds.
  (query: optimize table metric_log final;)

The merge itself is healthy and continues on the server; only the client gives
up while waiting. CIDB shows this exact signature on
`Stateless tests (amd_tsan, s3 storage, sequential)` on multiple PRs.

The fix follows the canonical pattern from 03015_optimize_final_rmt.sh and
attaches `SETTINGS receive_timeout = 900` to each of the two `OPTIMIZE FINAL`
statements. This is targeted and preserves what the test verifies — peak
memory of a wide-column merge controlled by
`max_merge_delayed_streams_for_parallel_write`. Nothing else is changed: same
1200 columns, same `s3_no_cache` storage policy, same merge settings.

Demonstrated in both directions on a local TSan+S3 reproduction:
- `--receive_timeout=30` reproduces the exact CIDB error.
- `SETTINGS receive_timeout = 900` makes the same OPTIMIZE complete in ~77s.
- Full test passes 3/3 end-to-end on TSan+S3 locally with the fix.

cc @PedroTadim — follow-up to ClickHouse#104543 review feedback.

CI report (example failure):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104543&sha=5c7df7cb24af2897820e687eab7d2b49d486b40d&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20sequential%2C%202%2F2%29
@clickhouse-gh

clickhouse-gh Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Dear @yariks5s, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@yariks5s

Copy link
Copy Markdown
Member

@groeneai please update your branch with master so the CI can be triggered again with fixed tests

alexey-milovidov and others added 2 commits June 29, 2026 10:49
The branch was created when 04218 was the next free number; master has
since reached 04416 and accumulated several other 04218_* tests. Use the
next available number so the test name is unambiguous.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

@yariks5s — done, branch is updated with master.

  • Merged current master into the branch (it was ~14.6k commits behind). The merge was clean — this is a test-only PR, no conflicts.
  • The fix for the previously-failing 03393_max_merge_delayed_streams_for_parallel_write (PR tests: fix 03393_max_merge_delayed_streams_for_parallel_write flakiness under TSan+S3 and in general #104697) merged into master on 2026-06-02, so it is now included in this branch and that TSan+S3 timeout should no longer recur.
  • Renumbered the test 04218_ → 04419_distributed_remote_datetime64_zero_71288: when the branch was first cut, 04218 was the next free number, but master has since reached 04416 and accumulated several other 04218_* tests. Using the next available number keeps it unambiguous.
  • Re-verified locally on master (26.7.1.1): both analyzer paths return 2/2 as expected.

The earlier review point from @alexey-milovidov was addressed in 5c7df7cb24a (switched to the canonical '127.0.0.{1,2}' form with the explicit dot). CI should now re-run green.

@alexey-milovidov

Copy link
Copy Markdown
Member

@yariks5s — re-synced the branch with current master again (it had drifted ~1 week / ~89k commits behind since the last update). The merge was clean — this is a test-only PR, no conflicts — and CI is re-running now on 0d96d762.

For the record, the only red on the previous run (62a107c3) was two Stress test logical errors, both of which are known, tracked issues unrelated to this PR (which just adds one stateless .sql regression test):

The added test 04419_distributed_remote_datetime64_zero_71288 itself passed 50/50 on every sanitizer flaky check. Should be green (modulo those unrelated random fuzzer hits) after this re-run.

@yariks5s yariks5s self-assigned this Jul 6, 2026
Add a non-matching row (epoch + 1s) alongside the epoch-zero row so that a
silently dropped remote WHERE r IN (...) filter yields count 4 instead of 2,
making the test fail if the filter path is lost, not only if the query errors.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
auto-merge was automatically disabled July 6, 2026 16:38

Head branch was pushed to by a user without write access

@groeneai

groeneai commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Good catch. Fixed in cb8539c.

The fixture now inserts a non-matching row (1000 = epoch + 1s) alongside the epoch-zero row:

CREATE TABLE test_71288 (r DateTime64(3)) ENGINE = Memory();
INSERT INTO test_71288 VALUES (0), (1000);

Now each shard holds 2 rows but only 1 matches the WHERE r IN (toDateTime64('1970-01-01 00:00:00.000', 3)) predicate. So:

  • filter working (both analyzer paths): count = 2 (matches .reference)
  • filter silently dropped -> unfiltered count = 4 != 2 -> test FAILS

Verified locally against a 2-shard remote() over master: filtered count is 2 on both analyzer=0 and analyzer=1, and an unfiltered count over the same two shards is 4. The test now gates the remote filter path, not just the parse error.

@alexey-milovidov

Copy link
Copy Markdown
Member

Updating the branch to fix the 04001_join_reorder_through_expression test, which was broken today in master.

@clickhouse-gh

clickhouse-gh Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.82% 85.83% +0.01%
Functions 91.47% 91.47% +0.00%
Branches 78.44% 78.48% +0.04%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 94 line(s), 5 function(s) across 43 file(s) · Details

Top files
  • src/Storages/MutationCommands.cpp: 6 line(s)
  • src/AggregateFunctions/AggregateFunctionQuantileExactInclusive.cpp: 5 line(s)
  • src/AggregateFunctions/AggregateFunctionDistinctDynamicTypes.cpp: 4 line(s), 1 function(s)
  • src/Functions/ULIDStringToDateTime.cpp: 4 line(s)
  • src/Functions/h3GetUnidirectionalEdgeBoundary.cpp: 4 line(s)

Full report

@groeneai

groeneai commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — c7e52c6

CI fully finished on head c7e52c67c3e7 (Finish Workflow: SUCCESS; 0 checks running). This is a test-only PR (adds 04419_distributed_remote_datetime64_zero_71288), so neither failure below is PR-caused. Every failure has an owner:

Check / test Reason Owner / fixing PR
Stateless (amd_debug / arm_binary, parallel) / 04001_join_reorder_through_expression flaky (retried; join-order randomization plan diff) #109499 (external, merged)
Stateless (amd_msan, WasmEdge, parallel, 2/2) / 01516_drop_table_stress_long flaky (msan-only, 2 hits/2 unrelated PRs/14d, 0 master) a fix task is created (investigating at full effort — fixing-PR link to follow here)
Mergeable Check / PR rollup owned above
Sync — CH Inc sync (private, not actionable)

No PR-caused failure. Approved by @yariks5s. Ready to merge.

Session id: cron:our-pr-ci-monitor:20260706-230000

@groeneai

groeneai commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the 01516_drop_table_stress_long flaky failure: #109587

@yariks5s
yariks5s added this pull request to the merge queue Jul 9, 2026
Merged via the queue into ClickHouse:master with commit 729ecb8 Jul 9, 2026
344 of 345 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 Jul 9, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Address @alexey-milovidov inline review on PR ClickHouse#104543:
ClickHouse#104543 (comment)

The address literal '127.0.0{1,2}' (no dot before the brace expansion)
expands to hosts 127.0.01 and 127.0.02. ClickHouse's lenient IP parsing
still resolves both to 127.0.0.1, so the test passed by accident — but
the form is non-idiomatic: every other test in tests/queries/0_stateless
uses '127.0.0.{1,2}' (20 files) with the explicit dot before the brace.

This commit switches to the canonical form. Verified locally with
--test-runs 50: 50/50 pass on master HEAD.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…8-datetime64-remote-zero

Add regression test for DateTime64 zero over remote() (issue ClickHouse#71288)
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 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.

When querying in the distributed engine, an error occurred "CANNOT_PARSE_DATETIME"

5 participants