Skip to content

LOGICAL_ERROR Shard number is greater than shard count with parallel replicas #81738

@nickitat

Description

@nickitat

Test:

set serialize_query_plan = 0;
drop table if exists t;
CREATE TABLE t(a UInt64, b UInt64) ENGINE = MergeTree ORDER BY a;

INSERT INTO t SELECT
    number,
    number
FROM numbers_mt(1000000);

SET enable_parallel_replicas = 1, parallel_replicas_local_plan = 1, max_parallel_replicas = 3, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', parallel_replicas_for_non_replicated_merge_tree = 1;
SET prefer_localhost_replica = 1, enable_analyzer = 1;

EXPLAIN SYNTAX
SELECT replaceRegexpAll(explain, 'ReadFromRemoteParallelReplicas.*', 'ReadFromRemoteParallelReplicas')
FROM
(
    SELECT *
    FROM viewExplain('EXPLAIN', 'distributed = 1', (
        SELECT a
        FROM remote('127.0.0.{1,2}', currentDatabase(), t)
        GROUP BY a
    ))
)

Thanks to @fm4v, we figured it out. To reproduce, one also needs this config:

<enable_analyzer>
    <readonly/>
</enable_analyzer>

from docker/test/fuzzer/query-fuzzer-tweaks-users.xml

Originally posted by @nickitat in #81610 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed user-visible misbehaviour in official releasecomp-parallel-replicasParallel reading from replicas for query speed (not data replication consistency).

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions