Skip to content

PR: distinct in order with disabled read in order optimization#75260

Open
devcrafter wants to merge 25 commits intomasterfrom
fix-pr-distinct-in-order
Open

PR: distinct in order with disabled read in order optimization#75260
devcrafter wants to merge 25 commits intomasterfrom
fix-pr-distinct-in-order

Conversation

@devcrafter
Copy link
Copy Markdown
Member

@devcrafter devcrafter commented Jan 30, 2025

optimize_read_in_order=0 leads to "Replica 1 decided to read in Default mode, not in WithOrder. This is a bug: While executing Remote. (LOGICAL_ERROR)"
02317_distinct_in_order_optimization

Fixes #75961

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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)

All builds in Builds_1 and Builds_2 stages are always mandatory and will run independently of the checks below:

  • Only: Stateless tests
  • Only: Integration tests
  • Only: Performance tests

  • Skip: Style check
  • Skip: Fast test

  • Run all checks ignoring all possible failures (Resource-intensive. All test jobs execute in parallel).
  • Disable CI cache

@devcrafter devcrafter marked this pull request as draft January 30, 2025 13:43
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jan 30, 2025
@robot-ch-test-poll3
Copy link
Copy Markdown
Contributor

robot-ch-test-poll3 commented Jan 30, 2025

This is an automated comment for commit 241acca 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
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (asan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (debug)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (msan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (tsan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (ubsan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns 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
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
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

@devcrafter devcrafter marked this pull request as ready for review February 5, 2025 10:07
@jkartseva jkartseva self-assigned this Feb 6, 2025
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 7, 2025

Workflow [PR], commit [a10e1bb]

@devcrafter
Copy link
Copy Markdown
Member Author

@jkartseva
Copy link
Copy Markdown
Member

jkartseva commented Feb 10, 2025

The 00278_insert_already_sorted test doesn't look flaky on master

Copy link
Copy Markdown
Member

@jkartseva jkartseva left a comment

Choose a reason for hiding this comment

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

LGTM. 03352_concurrent_rename_alter is flaky on master

@jkartseva
Copy link
Copy Markdown
Member

@devcrafter
Copy link
Copy Markdown
Member Author

It turns out the issue is wider, - any in order optimization can lead to different reading modes on local and remote node. The straight option is to disable in order optimizations with PR, but it looks too much.

A proper solution could be restricting optimization scope for local plan (on initiator)
The issue is happening only with parallel_replicas_local_plan enabled (which considered as the main mode for PR)
The problem appears in queries with subqueries where subquery is sent to a remote node for execution first (i.e. not the entire query). So, on initiator the entire query is optimized but on remote nodes only subquery is optimized. And as an outcome, optimization of the entire query, and the optimization of only subquery, can lead to different modes of reading from MergeTree table.

The way to fix it is to restrict optimization scope on initiator for local plan, so the in order optimization will not be pushed down to subquery reading step

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Apr 8, 2025

Dear @jkartseva, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@jkartseva jkartseva self-assigned this Apr 8, 2025
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented May 13, 2025

Dear @jkartseva, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@alexey-milovidov
Copy link
Copy Markdown
Member

@devcrafter, exactly the same bug appears in the results of the checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parallel replicas: logical error: Replica 0 decided to read in Default mode, not in WithOrder. This is a bug

5 participants