Skip to content

Fix: LOGICAL_ERROR in PR with aggregation in order - #95306

Closed
devcrafter wants to merge 10 commits into
masterfrom
fix-pr-aggr-in-order-read-mode
Closed

devcrafter wants to merge 10 commits into
masterfrom
fix-pr-aggr-in-order-read-mode

Conversation

@devcrafter

@devcrafter devcrafter commented Jan 27, 2026 •

Copy link
Copy Markdown
Member

Try to fix #95524

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 into CHANGELOG.md):

Fix for Replica 1 decided to read in WithOrder mode, not in ReverseOrder logical error with enabled parallel replicas and aggregation in order

@devcrafter
devcrafter marked this pull request as draft January 27, 2026 13:44
@clickhouse-gh

clickhouse-gh Bot commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [663703f]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan, targeted) failure
00177_memory_bound_merging FAIL cidb
02404_memory_bound_merging FAIL cidb
Stateless tests (amd_asan, distributed plan, parallel, 1/2) failure
00177_memory_bound_merging FAIL cidb
Stateless tests (amd_asan, db disk, distributed plan, sequential) failure
02404_memory_bound_merging FAIL cidb
Stateless tests (amd_binary, old analyzer, s3 storage, DatabaseReplicated, sequential) failure
02404_memory_bound_merging FAIL cidb
Stateless tests (amd_binary, ParallelReplicas, s3 storage, sequential) failure
02404_memory_bound_merging FAIL cidb
Stateless tests (amd_debug, AsyncInsert, s3 storage, sequential) failure
02404_memory_bound_merging FAIL cidb
Stateless tests (amd_debug, parallel) failure
00177_memory_bound_merging FAIL cidb
Stateless tests (amd_debug, sequential) failure
02404_memory_bound_merging FAIL cidb
Stateless tests (amd_tsan, parallel, 1/2) failure
00177_memory_bound_merging FAIL cidb
Stateless tests (amd_tsan, sequential, 2/2) failure
02404_memory_bound_merging FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jan 27, 2026
@devcrafter
devcrafter requested a review from Copilot January 27, 2026 16:00
@devcrafter
devcrafter marked this pull request as ready for review January 27, 2026 16:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a LOGICAL_ERROR that occurs when parallel replicas are enabled alongside the "aggregation in order" optimization. The error manifested as "Replica 1 decided to read in WithOrder mode, not in ReverseOrder" due to different read modes being selected on local vs. remote replicas caused by inconsistent filter pushdown behavior.

Changes:

  • Disables the optimize_aggregation_in_order setting when parallel_replicas_local_plan is enabled to prevent read mode mismatches
  • Adds a failpoint to detect and report read mode inconsistencies during testing
  • Includes a regression test that reproduces the original error condition

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
src/Interpreters/ClusterProxy/executeQuery.cpp Adds logic to disable aggregation in order optimization when parallel replicas use local query plans, with appropriate logging
src/Storages/MergeTree/ParallelReplicasReadingCoordinator.cpp Adds failpoint check to detect read mode mismatches between replicas for testing purposes
src/Common/FailPoint.cpp Registers new failpoint for read mode validation
tests/queries/0_stateless/03810_pr_aggr_in_order_read_mode.sql Adds regression test that exercises the fixed scenario

@devcrafter
devcrafter force-pushed the fix-pr-aggr-in-order-read-mode branch from 2adc7ae to 2c902b7 Compare January 27, 2026 19:43
@clickhouse-gh

clickhouse-gh Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Dear @KochetovNicolai, 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.

@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Dear @KochetovNicolai, 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.

@devcrafter

Copy link
Copy Markdown
Member Author

Fixed by #98467

@devcrafter devcrafter closed this Jul 29, 2026
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.

PR: Replica 1 decided to read in WithOrder mode, not in ReverseOrder

3 participants