Skip to content

Fix small value DateTime64 constant folding in nested subquery for remote#68323

Merged
Avogar merged 4 commits intoClickHouse:masterfrom
shiyer7474:fix_datetime64_const_in_subquery_distributed
Aug 21, 2024
Merged

Fix small value DateTime64 constant folding in nested subquery for remote#68323
Avogar merged 4 commits intoClickHouse:masterfrom
shiyer7474:fix_datetime64_const_in_subquery_distributed

Conversation

@shiyer7474
Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixes #50868. Small DateTime64 constant values returned by a nested subquery inside a distributed query were wrongly transformed to Nulls, thus causing errors and possible incorrect query results.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

CI Settings (Only check the boxes if you know what you are doing):

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64, release, debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

@shiyer7474
Copy link
Copy Markdown
Contributor Author

Related :-
PR #67920
Issue #66773

Current PR handles the case of nested subquery inside a remote/distributed query. A nested subquery requires additional check for Nullable type in ConstantNode::toASTImpl() (the Nullable type's inner type could be DateTime64). For reference, below is example of AST serialization of nested subquery containing a DateTime64 constant folded value

select *, (select toDateTime64(0, 3)) from remote('127.0.0.1', system.one) settings prefer_localhost_replica=0;
|
v
"SELECT `__table1`.`dummy` AS `dummy`, _CAST('0', 'Nullable(DateTime64(0,3))') AS `_subquery_1
` FROM `system`.`one` AS `__table1`"

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 16, 2024
@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Aug 16, 2024
@robot-clickhouse-ci-2
Copy link
Copy Markdown
Contributor

robot-clickhouse-ci-2 commented Aug 16, 2024

This is an automated comment for commit 6ee9cad with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
Bugfix validationChecks that either a new test (functional or integration) or there some changed tests that fail with the binary built on master branch✅ success
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@Avogar Avogar self-assigned this Aug 19, 2024
@shiyer7474
Copy link
Copy Markdown
Contributor Author

Analyzed the test failures in latest run, they should not be related to this PR :

2024-08-19 11:26:18 03221_s3_imds_decent_timeout:                                           [ FAIL ] 7.26 sec.
2024-08-19 18:27:54 01624_soft_constraints:                                                 [ FAIL ] 27.37 sec.
2024-08-19 18:30:56 01290_max_execution_speed_distributed:                                  [ FAIL ] 4.02 sec.
2024-08-19 18:32:27 00653_verification_monotonic_data_load:                                 [ FAIL ] 600.05 sec.
2024-08-19 18:41:46 02944_variant_as_common_type:                                           [ FAIL ] 2.34 sec.

Not clear what happened in this test suite -
[Tests_2 / s (AST fuzzer (asan), fuzzer-unit-tester) / AST fuzzer (asan]


2024-08-19 17:48:42	 + fuzzer_exit_code=143
2024-08-19 17:48:42	 + echo 'Fuzzer exit code is 143'
2024-08-19 17:48:42	 Fuzzer exit code is 143
2024-08-19 17:48:42	 + for _ in {1..100}
2024-08-19 17:48:42	 + clickhouse-client --query 'SELECT 1'
2024-08-19 17:48:46	 1
2024-08-19 17:48:46	 + server_died=0
2024-08-19 17:48:46	 + break
2024-08-19 17:48:46	 + server_exit_code=0
2024-08-19 17:48:46	 + wait 169
2024-08-19 17:48:46	 + stop_server
2024-08-19 17:48:46	 + clickhouse-client --query 'select elapsed, query from system.processes'
2024-08-19 17:48:46	 ch/docker/test/fuzzer/run-fuzzer.sh: line 324: wait: pid 169 is not a child of this shell
2024-08-19 17:48:46	 + server_exit_code=127
2024-08-19 17:48:46	 + echo 'Server exit code is 127'
2024-08-19 17:48:46	 Server exit code is 127
2024-08-19 17:48:46	 + task_exit_code=143
2024-08-19 17:48:46	 + '[' 0 == 1 ']'
2024-08-19 17:48:46	 + '[' 143 == 143 ']'
2024-08-19 17:48:46	 + task_exit_code=0
2024-08-19 17:48:46	 + echo success
2024-08-19 17:48:46	 + echo OK
2024-08-19 17:48:46	 + test -f 'core.*'
2024-08-19 17:48:46	 + dmesg -T
2024-08-19 17:48:46	 + rg -q -F -e 'Out of memory: Killed process' -e 'oom_reaper: reaped process' -e oom-kill:constraint=CONSTRAINT_NONE
2024-08-19 17:48:46	 + :
2024-08-19 17:48:46	 
2024-08-19 17:48:46	 real	30m25.472s
2024-08-19 17:48:46	 user	1m28.159s
2024-08-19 17:48:46	 sys	0m19.928s
2024-08-19 17:48:46	 + CORE_LINK=
2024-08-19 17:48:46	 + '[' -f core.zst ']'
2024-08-19 17:48:46	 + sed -n '/<Fatal>/,/^$/p' server.log
2024-08-19 17:48:46	 + awk '/<Fatal>/ || !/^20/'
2024-08-19 17:48:46	 0.005477	select elapsed, query from system.processes
2024-08-19 17:48:46	 + clickhouse stop
2024-08-19 17:48:50	 + FATAL_LINK=
2024-08-19 17:48:50	 + '[' -s fatal.log ']'
2024-08-19 17:48:50	 + dmesg -T
2024-08-19 17:48:50	 + zstd --threads=0 --rm server.log
2024-08-19 17:48:52	 
                                                                               
Read :  0 / 452 MB ==>  0%
                                                                               
Read : 16 / 452 MB ==>  4%
                                                                               
Read : 40 / 452 MB ==>  5%
                                                                               
Read : 56 / 452 MB ==>  5%
                                                                               
Read : 72 / 452 MB ==>  5%
                                                                               
Read : 96 / 452 MB ==>  4%
                                                                               
Read : 112 / 452 MB ==>  4%
                                                                               
Read : 136 / 452 MB ==>  5%
                                                                               
Read : 152 / 452 MB ==>  4%
                                                                               
Read : 176 / 452 MB ==>  4%
                                                                               
Read : 192 / 452 MB ==>  4%
                                                                               
Read : 208 / 452 MB ==>  4%
                                                                               
Read : 224 / 452 MB ==>  4%
                                                                               
Read : 232 / 452 MB ==>  4%
                                                                               
Read : 256 / 452 MB ==>  4%
                                                                               
Read : 272 / 452 MB ==>  4%zstd: error 27 : Read error : Incomplete read : 474095811 / 474087142 B 
2024-08-19 17:48:52	 
2024-08-19 17:48:52	 real	32m3.128s
2024-08-19 17:48:52	 user	1m39.666s
2024-08-19 17:48:52	 sys	0m30.047s
2024-08-19 17:48:53	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 169.
2024-08-19 17:48:53	 The process with pid = 169 is running.
2024-08-19 17:48:53	 Sent terminate signal to process with pid 169.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 169.
2024-08-19 17:48:53	 The process with pid = 169 is running.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 169.
2024-08-19 17:48:53	 The process with pid = 169 is running.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 169.
2024-08-19 17:48:53	 The process with pid = 169 is running.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 169.
2024-08-19 17:48:53	 The process with pid = 169 is running.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 169.
2024-08-19 17:48:53	 The process with pid = 169 is running.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 Found pid = 169 in the list of running processes.
2024-08-19 17:48:53	 The process with pid = 169 is running.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 Found pid = 1462 in the list of running processes.
2024-08-19 17:48:53	 The process with pid = 1462 is running.
2024-08-19 17:48:53	 Waiting for server to stop
2024-08-19 17:48:53	 Now there is no clickhouse-server process.
2024-08-19 17:48:53	 Server stopped
2024-08-19 17:48:53	 + date
2024-08-19 17:48:53	 Mon Aug 19 05:48:53 PM CEST 2024
2024-08-19 17:48:53	 + sleep 10
2024-08-19 17:49:03	 + jobs
2024-08-19 17:49:03	 + pstree -aspgT
2024-08-19 17:49:03	 bash,1,1 -cset -o pipefail     && cd /workspace     && timeout -s 9 1h /run-fuzzer.sh 2>&1 | ts "$(printf '%%Y-%%m-%%d %%H:%%M:%%S
2024-08-19 17:49:03	   |-run-fuzzer.sh,1442,7 ch/docker/test/fuzzer/run-fuzzer.sh
2024-08-19 17:49:03	   |   `-pstree,1470,7 -aspgT
2024-08-19 17:49:03	   |-tee,9,1 main.log
2024-08-19 17:49:03	   `-ts,8,1 /usr/bin/ts %Y-%m-%d %H:%M:%S\011
INFO:root:Run failed
INFO:root:Result: 'success', 'OK'
Run action done for: [AST fuzzer (asan)]
{}
Error: The operation was canceled.

@Avogar Please recommend next step. Can the AST Fuzzer (ASAN) be rerun?

@shiyer7474
Copy link
Copy Markdown
Contributor Author

3 of test failures have been reported earlier :-

#67769
#68579

@shiyer7474
Copy link
Copy Markdown
Contributor Author

Investigating timeout failure in 00653_verification_monotonic_data_load in :

#68626

@shiyer7474
Copy link
Copy Markdown
Contributor Author

Current Status : The 5 Stateless test failures are seen by other PRs also and are flaky tests. Regarding possible error in "AST fuzzer (asan)", cause is not clear and hopefully should be clear in rerun.

@shiyer7474
Copy link
Copy Markdown
Contributor Author

For "AST fuzzer (asan)", I see similar run.log on the latest master commit -
054b38d
https://github.com/ClickHouse/ClickHouse/actions/runs/10478594231/job/29031501110

2024-08-20 23:53:19	 + fuzzer_exit_code=143
2024-08-20 23:53:19	 + echo 'Fuzzer exit code is 143'
2024-08-20 23:53:19	 Fuzzer exit code is 143
2024-08-20 23:53:19	 + for _ in {1..100}
2024-08-20 23:53:19	 + clickhouse-client --query 'SELECT 1'
2024-08-20 23:53:19	 1
2024-08-20 23:53:19	 + server_died=0
2024-08-20 23:53:19	 + break
2024-08-20 23:53:19	 + server_exit_code=0
2024-08-20 23:53:19	 + wait 172
2024-08-20 23:53:19	 + stop_server
2024-08-20 23:53:19	 ch/docker/test/fuzzer/run-fuzzer.sh: line 324: wait: pid 172 is not a child of this shell
2024-08-20 23:53:19	 + server_exit_code=127
2024-08-20 23:53:19	 + clickhouse-client --query 'select elapsed, query from system.processes'
2024-08-20 23:53:19	 + echo 'Server exit code is 127'
2024-08-20 23:53:19	 Server exit code is 127
2024-08-20 23:53:19	 + task_exit_code=143
2024-08-20 23:53:19	 + '[' 0 == 1 ']'
2024-08-20 23:53:19	 + '[' 143 == 143 ']'
2024-08-20 23:53:19	 + task_exit_code=0
2024-08-20 23:53:19	 + echo success
2024-08-20 23:53:19	 + echo OK
2024-08-20 23:53:19	 + test -f 'core.*'
2024-08-20 23:53:19	 + dmesg -T
2024-08-20 23:53:19	 + rg -q -F -e 'Out of memory: Killed process' -e 'oom_reaper: reaped process' -e oom-kill:constraint=CONSTRAINT_NONE
2024-08-20 23:53:19	 + :
2024-08-20 23:53:19	 
2024-08-20 23:53:19	 real	30m26.998s
2024-08-20 23:53:19	 user	6m7.908s
2024-08-20 23:53:19	 sys	0m35.591s
2024-08-20 23:53:19	 + CORE_LINK=
2024-08-20 23:53:19	 + '[' -f core.zst ']'
2024-08-20 23:53:19	 + sed -n '/<Fatal>/,/^$/p' server.log
2024-08-20 23:53:19	 + awk '/<Fatal>/ || !/^20/'
2024-08-20 23:53:19	 0.004502	select elapsed, query from system.processes
2024-08-20 23:53:19	 + clickhouse stop
2024-08-20 23:53:21	 + FATAL_LINK=
2024-08-20 23:53:21	 + '[' -s fatal.log ']'
2024-08-20 23:53:21	 + dmesg -T
2024-08-20 23:53:21	 + zstd --threads=0 --rm server.log
2024-08-20 23:53:22	 
                                                                               
Read :  0 / 1288 MB ==>  0%
                                                                               
Read : 332 / 1288 MB ==>  2%
                                                                               
Read : 746 / 1288 MB ==>  2%
                                                                               
Read : 1171 / 1288 MB ==>  2%zstd: error 27 : Read error : Incomplete read : 1351485955 / 1351484431 B 
2024-08-20 23:53:22	 
2024-08-20 23:53:22	 real	31m54.314s
2024-08-20 23:53:22	 user	6m27.256s
2024-08-20 23:53:22	 sys	0m44.719s
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Sent terminate signal to process with pid 172.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 172.
2024-08-20 23:53:27	 The process with pid = 172 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 Found pid = 1454 in the list of running processes.
2024-08-20 23:53:27	 The process with pid = 1454 is running.
2024-08-20 23:53:27	 Waiting for server to stop
2024-08-20 23:53:27	 Now there is no clickhouse-server process.
2024-08-20 23:53:27	 Server stopped
2024-08-20 23:53:28	 + date
2024-08-20 23:53:28	 Tue Aug 20 11:53:28 PM CEST 2024
2024-08-20 23:53:28	 + sleep 10
2024-08-20 23:53:38	 + jobs
2024-08-20 23:53:38	 + pstree -aspgT
2024-08-20 23:53:38	 bash,1,1 -cset -o pipefail     && cd /workspace     && timeout -s 9 1h /run-fuzzer.sh 2>&1 | ts "$(printf '%%Y-%%m-%%d %%H:%%M:%%S
2024-08-20 23:53:38	   |-run-fuzzer.sh,1436,7 ch/docker/test/fuzzer/run-fuzzer.sh
2024-08-20 23:53:38	   |   `-pstree,1462,7 -aspgT
2024-08-20 23:53:38	   |-tee,9,1 main.log
2024-08-20 23:53:38	   `-ts,8,1 /usr/bin/ts %Y-%m-%d %H:%M:%S\011
INFO:root:Run failed
INFO:root:Result: 'success', 'OK'
Run action done for: [AST fuzzer (asan)]
{}

@Avogar
Copy link
Copy Markdown
Member

Avogar commented Aug 21, 2024

Thank you! We will fix all flaky tests

robot-clickhouse added a commit that referenced this pull request Aug 22, 2024
Backport #68323 to 24.8: Fix small value DateTime64 constant folding in nested subquery for remote
@shiyer7474 shiyer7474 deleted the fix_datetime64_const_in_subquery_distributed branch August 23, 2024 03:51
robot-clickhouse added a commit that referenced this pull request Aug 26, 2024
robot-clickhouse added a commit that referenced this pull request Aug 26, 2024
robot-clickhouse added a commit that referenced this pull request Aug 26, 2024
robot-clickhouse added a commit that referenced this pull request Aug 26, 2024
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 26, 2024
robot-ch-test-poll4 added a commit that referenced this pull request Aug 28, 2024
Backport #68323 to 24.3: Fix small value DateTime64 constant folding in nested subquery for remote
robot-clickhouse-ci-1 added a commit that referenced this pull request Aug 28, 2024
Backport #68323 to 24.7: Fix small value DateTime64 constant folding in nested subquery for remote
robot-clickhouse-ci-1 added a commit that referenced this pull request Aug 28, 2024
Backport #68323 to 24.5: Fix small value DateTime64 constant folding in nested subquery for remote
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created-cloud deprecated label, NOOP label Aug 28, 2024
Avogar added a commit that referenced this pull request Aug 29, 2024
Backport #68323 to 24.6: Fix small value DateTime64 constant folding in nested subquery for remote
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-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

7 participants