Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix optimize_skip_unused_shards with JOINs #51037

Conversation

azat
Copy link
Collaborator

@azat azat commented Jun 15, 2023

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

Fix optimize_skip_unused_shards with JOINs (when the query contains some filters for the JOINed tables)

In case of JOIN query may contains conditions for other tables, while optimize_skip_unused_shards was pretty dumb and failed to skip such columns.

Fix this by removing JOIN before applying this optimization.

Fixes: #15995

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-bugfix Pull request with bugfix, not backported by default label Jun 15, 2023
@robot-clickhouse-ci-1
Copy link
Contributor

robot-clickhouse-ci-1 commented Jun 15, 2023

This is an automated comment for commit d9d8782 with description of existing statuses. It's updated for the latest CI running
The full report is available here
The overall status of the commit is 🔴 failure

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 validate checkChecks that either a new test (functional or integration) or there some changed tests that fail with the binary built on master branch🟢 success
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR🟢 success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process🟢 success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help🟢 success
Docker image for serversThe check to build and optionally push the mentioned image to docker hub🟢 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. Integrational 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🔴 failure
Mergeable CheckChecks if all other necessary checks are successful🟢 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
Push to DockerhubThe check for building and pushing the CI related docker images to docker hub🟢 success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool🟢 success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed🟢 success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc🟢 success
Stateless testsRuns stateless 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

@azat azat force-pushed the dist/optimize_skip_unused_shards-join-fix branch 2 times, most recently from af11df5 to 78de102 Compare June 15, 2023 20:47
@azat
Copy link
Collaborator Author

azat commented Jun 29, 2023

Can someone take a look please?

@azat
Copy link
Collaborator Author

azat commented Jul 7, 2023

Kind ping, looks like this got lost

@alexey-milovidov alexey-milovidov self-assigned this Jul 8, 2023
@azat
Copy link
Collaborator Author

azat commented Jul 9, 2023

Test failures are not related (and they fail in upstream/master as well):

Integration tests (asan) [5/6] — fail: 36, passed: 389, flaky: 0

  • test_storage_s3
>       raise Exception("Can't wait Minio to start")
E       Exception: Can't wait Minio to start

Integration tests (tsan) [1/6] — fail: 2, passed: 356, flaky: 0

  • test_ttl_replicated/test.py::test_ttl_alter_delete[test_ttl_alter_delete_replicated] - Coordination::Exception: Connection loss, path: /clickhouse/test_replicated_ttl_alter_delete/replicas/1/queue/queue-0000000001

  • test_rename_column/test.py::test_rename_with_parallel_slow_insert - Wrong column name. Cannot find column foo2 to rename

@azat azat force-pushed the dist/optimize_skip_unused_shards-join-fix branch from a333d92 to f48b078 Compare July 12, 2023 13:25
@alexey-milovidov
Copy link
Member

Tests have failed.

@alexey-milovidov
Copy link
Member

@azat let's investigate and fix the unrelated tests.

@azat
Copy link
Collaborator Author

azat commented Jul 13, 2023

Ok, though it sometimes kind of a chicken and egg problem...

Integration tests (tsan) [4/6] — fail: 2, passed: 273, flaky: 0

I will not look at analyzer tests for now.

@azat
Copy link
Collaborator Author

azat commented Jul 13, 2023

Actually the newly added test SIGSEGV server with analyzer, will take a look

@azat azat marked this pull request as draft July 13, 2023 14:16
@azat azat force-pushed the dist/optimize_skip_unused_shards-join-fix branch from f48b078 to 3c303cc Compare July 13, 2023 16:15
@azat
Copy link
Collaborator Author

azat commented Jul 13, 2023

Ok, for now I simply disabled it for analyzer, since there are lots of other tests that fails because of optimize_skip_unused_shards does not work with analyzer (actually not simply "it does not work" but instead it crashes the server). Will take a look separately into this.

@azat azat marked this pull request as ready for review July 13, 2023 16:15
@azat azat force-pushed the dist/optimize_skip_unused_shards-join-fix branch 2 times, most recently from e66b7a6 to bae2b4a Compare July 16, 2023 05:48
@azat
Copy link
Collaborator Author

azat commented Jul 22, 2023

Stateless tests (release) — Tests are not finished, fail: 7, passed: 2165, skipped: 2

2023.07.22 04:41:57.459845 [ 181544 ] {} <Fatal> BaseDaemon: ########## Short fault info ############
2023.07.22 04:41:57.459919 [ 181544 ] {} <Fatal> BaseDaemon: (version 23.7.1.1798, build id: A5A79B1F75944A5EA4A97E49C08C4254090245A2, git hash: a5bcbd834ef2e8f859bd15ef6ef084c13484fd69) (from thread 55667) Received signal 11
2023.07.22 04:41:57.460422 [ 181544 ] {} <Fatal> BaseDaemon: Signal description: Segmentation fault
2023.07.22 04:41:57.460437 [ 181544 ] {} <Fatal> BaseDaemon: Address: 0x7ef6a99ea440. Access: read. Address not mapped to object.
2023.07.22 04:41:57.460446 [ 181544 ] {} <Fatal> BaseDaemon: Stack trace: 0x0000000014e264fd 0x0000000014e2931e 0x0000000014e41f10 0x0000000014e43c68 0x000000001318b5c3
2023.07.22 04:41:57.460452 [ 181544 ] {} <Fatal> BaseDaemon: ########################################
2023.07.22 04:41:57.460490 [ 181544 ] {} <Fatal> BaseDaemon: (version 23.7.1.1798, build id: A5A79B1F75944A5EA4A97E49C08C4254090245A2, git hash: a5bcbd834ef2e8f859bd15ef6ef084c13484fd69) (from thread 55667) (query_id: 5de596ad-96bb-4853-a96f-3a5d4fbbc3aa) (query: -- these are just in case
2023.07.22 04:41:57.460530 [ 181544 ] {} <Fatal> BaseDaemon: Address: 0x7ef6a99ea440. Access: read. Address not mapped to object.
2023.07.22 04:41:57.460573 [ 181544 ] {} <Fatal> BaseDaemon: Stack trace: 0x0000000014e264fd 0x0000000014e2931e 0x0000000014e41f10 0x0000000014e43c68 0x000000001318b5c3
2023.07.22 04:41:57.504883 [ 181544 ] {} <Fatal> BaseDaemon: 2.1. inlined from ./build_docker/./src/Common/CurrentThread.cpp:95: DB::CurrentThread::getGroup()
2023.07.22 04:41:57.504926 [ 181544 ] {} <Fatal> BaseDaemon: 2. ./build_docker/./src/Client/Connection.cpp:194: DB::Connection::connect(DB::ConnectionTimeouts const&) @ 0x0000000014e264fd in /usr/lib/debug/usr/bin/clickhouse.debug
2023.07.22 04:41:57.551269 [ 181544 ] {} <Fatal> BaseDaemon: 3. ./build_docker/./src/Client/Connection.cpp:434: DB::Connection::getServerRevision(DB::ConnectionTimeouts const&) @ 0x0000000014e2931e in /usr/lib/debug/usr/bin/clickhouse.debug
2023.07.22 04:41:57.556879 [ 181544 ] {} <Fatal> BaseDaemon: 4. ./build_docker/./src/Client/ConnectionEstablisher.cpp:0: DB::ConnectionEstablisher::run(PoolWithFailoverBase<DB::IConnectionPool>::TryResult&, String&) @ 0x0000000014e41f10 in /usr/lib/debug/usr/bin/clickhouse.debug
2023.07.22 04:41:57.563450 [ 181544 ] {} <Fatal> BaseDaemon: 5. ./build_docker/./src/Client/ConnectionEstablisher.cpp:129: DB::ConnectionEstablisherAsync::Task::run(std::function<void (int, Poco::Timespan, DB::AsyncEventTimeoutType, String const&, unsigned int)>, std::function<void ()>) @ 0x0000000014e43c68 in /usr/lib/debug/usr/bin/clickhouse.debug
2023.07.22 04:41:57.567055 [ 181544 ] {} <Fatal> BaseDaemon: 6.1. inlined from ./build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:818: ~__policy_func
2023.07.22 04:41:57.567081 [ 181544 ] {} <Fatal> BaseDaemon: 6.2. inlined from ./build_docker/./contrib/llvm-project/libcxx/include/__functional/function.h:1174: ~function
2023.07.22 04:41:57.567089 [ 181544 ] {} <Fatal> BaseDaemon: 6.3. inlined from ./build_docker/./src/Common/AsyncTaskExecutor.cpp:84: DB::AsyncTaskExecutor::Routine::operator()(std::function<void ()>)
2023.07.22 04:41:57.567104 [ 181544 ] {} <Fatal> BaseDaemon: 6.4. inlined from ./build_docker/./src/Common/Fiber.h:70: Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>::operator()(boost::context::fiber&&)
2023.07.22 04:41:57.567134 [ 181544 ] {} <Fatal> BaseDaemon: 6.5. inlined from ./build_docker/./contrib/llvm-project/libcxx/include/__functional/invoke.h:394: decltype(std::declval<Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>&>()(std::declval<boost::context::fiber>())) std::__invoke[abi:v15000]<Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>&, boost::context::fiber>(Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>&, boost::context::fiber&&)
2023.07.22 04:41:57.567161 [ 181544 ] {} <Fatal> BaseDaemon: 6.6. inlined from ./build_docker/./contrib/llvm-project/libcxx/include/__functional/invoke.h:531: std::invoke_result<Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>&, boost::context::fiber>::type std::invoke<Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>&, boost::context::fiber>(Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>&, boost::context::fiber&&)
2023.07.22 04:41:57.567184 [ 181544 ] {} <Fatal> BaseDaemon: 6.7. inlined from ./build_docker/./contrib/boost/boost/context/fiber_fcontext.hpp:140: boost::context::detail::fiber_record<boost::context::fiber, FiberStack&, Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>>::run(void*)
2023.07.22 04:41:57.567196 [ 181544 ] {} <Fatal> BaseDaemon: 6. ./build_docker/./contrib/boost/boost/context/fiber_fcontext.hpp:80: void boost::context::detail::fiber_entry<boost::context::detail::fiber_record<boost::context::fiber, FiberStack&, Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>>>(boost::context::detail::transfer_t) @ 0x000000001318b5c3 in /usr/lib/debug/usr/bin/clickhouse.debug
2023.07.22 04:41:57.567212 [ 181544 ] {} <Fatal> BaseDaemon: Integrity check of the executable skipped because the reference checksum could not be read.
2023.07.22 04:45:51.336105 [ 181544 ] {} <Fatal> BaseDaemon: This ClickHouse version is not official and should be upgraded to the official build.
2023.07.22 04:45:51.336421 [ 181544 ] {} <Fatal> BaseDaemon: Changed settings: min_compress_block_size = 485474, max_compress_block_size = 2709195, max_block_size = 70920, max_insert_threads = 9, max_threads = 49, max_read_buffer_size = 882071, connect_timeout_with_failover_ms = 2000, connect_timeout_with_failover_secure_ms = 3000, idle_connection_timeout = 36000, s3_check_objects_after_upload = true, stream_like_engine_allow_direct_select = true, replication_wait_for_inactive_replica_timeout = 30, compile_sort_description = false, group_by_two_level_threshold = 132797, enable_memory_bound_merging_of_aggregation_results = false, allow_nonconst_timezone_arguments = true, input_format_parallel_parsing = false, min_chunk_bytes_for_parallel_parsing = 3183790, merge_tree_coarse_index_granularity = 2, min_bytes_to_use_direct_io = 10737418240, min_bytes_to_use_mmap_io = 10737418240, log_queries = true, insert_quorum_timeout = 60000, http_wait_end_of_query = true, http_response_buffer_size = 2361003, fsync_metadata = true, http_send_timeout = 60., http_receive_timeout = 60., opentelemetry_start_trace_probability = 0.10000000149011612, max_untracked_memory = 1048576, memory_profiler_step = 1048576, log_comment = '01752_distributed_query_sigsegv.sql', send_logs_level = 'fatal', aggregation_in_order_max_block_bytes = 43690721, read_in_order_two_level_merge_threshold = 58, database_atomic_wait_for_drop_and_detach_synchronously = true, local_filesystem_read_method = 'io_uring', local_filesystem_read_prefetch = true, async_insert_busy_timeout_ms = 5000, enable_filesystem_cache = true, enable_filesystem_cache_on_write_operations = true, load_marks_asynchronously = true, allow_prefetched_read_pool_for_remote_filesystem = true, allow_prefetched_read_pool_for_local_filesystem = false, filesystem_prefetch_min_bytes_for_single_read_task = 16777216, filesystem_prefetch_max_memory_usage = 67108864, insert_keeper_max_retries = 20, insert_keeper_fault_injection_probability = 0.009999999776482582, optimize_distinct_in_order = false
2023.07.22 04:45:55.591346 [ 715 ] {} <Fatal> Application: Child process was terminated by signal 11.

In case of JOIN query may contains conditions for other tables, while
optimize_skip_unused_shards was pretty dumb and failed to skip such
columns.

Fix this by removing JOIN before applying this optimization.

v2: restriction for analyzer
v3: ignore 01940_custom_tld_sharding_key under analyzer
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
Co-Authored-By: Alexey Milovidov <milovidov@clickhouse.com>
@azat azat force-pushed the dist/optimize_skip_unused_shards-join-fix branch from 56df1ea to 20625d7 Compare July 22, 2023 05:45
@azat
Copy link
Collaborator Author

azat commented Jul 23, 2023

Integration tests (tsan) [5/6] — fail: 2, passed: 434

@alexey-milovidov alexey-milovidov merged commit f17844e into ClickHouse:master Jul 24, 2023
270 of 271 checks passed
@azat azat deleted the dist/optimize_skip_unused_shards-join-fix branch July 25, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception when using optimize_skip_unused_shards = 1
3 participants