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

planner: invalid Agg mode on MPP plans with sub-queries accessing partitioning tables under static partition mode #51362

Closed
qw4990 opened this issue Feb 27, 2024 · 6 comments · Fixed by #53455
Assignees
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. report/customer Customers have encountered this bug. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug. type/regression

Comments

@qw4990
Copy link
Contributor

qw4990 commented Feb 27, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t (
  d date,
  v int,
  primary key(d, v)
) partition by range columns (d) (
  partition p1 values less than ('2023-07-02'),
  partition p2 values less than ('2023-07-03')
);

alter table t set tiflash replica 1;
set tidb_partition_prune_mode='static';
select * from information_schema.tiflash_replica; -- wait until the replication progress finish

select 1 from (
  select /*+ read_from_storage(tiflash[t]) */ sum(1)
  from t where d BETWEEN '2023-07-01' and '2023-07-03' group by d
) total;
ERROR 1105 (HY000): other error for mpp stream: Code: 0, e.displayText() = DB::TiFlashException: Different aggregation mode detected, e.what() = DB::TiFlashException,

2. What did you expect to see? (Required)

No error

3. What did you see instead (Required)

ERROR 1105 (HY000): other error for mpp stream: Code: 0, e.displayText() = DB::TiFlashException: Different aggregation mode detected, e.what() = DB::TiFlashException,

4. What is your TiDB version? (Required)

@qw4990 qw4990 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/moderate labels Feb 27, 2024
@qw4990
Copy link
Contributor Author

qw4990 commented Feb 27, 2024

The root cause is that for this query, the optimizer uses partial AggMode and final AggMode together in a single HashAgg operator (HashAgg_58 in this case), but TiFlash doesn't support this use case, it doesn't allow user to use final and non-final mode in the same Agg operator (see the snippet below):
image
image

TiKV can support this usage:
image

@ti-chi-bot ti-chi-bot added the affects-7.5 This bug affects the 7.5.x(LTS) versions. label Feb 28, 2024
@kennedy8312
Copy link

/type regression

@kennedy8312
Copy link

Regression Analysis
The issue was seen on v7.5.0 but not v6.1.0.

mysql> select * from information_schema.tiflash_replica;
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_ID | REPLICA_COUNT | LOCATION_LABELS | AVAILABLE | PROGRESS |
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| test | t | 77 | 1 | | 1 | 1 |
+--------------+------------+----------+---------------+-----------------+-----------+----------+
1 row in set (0.01 sec)

mysql> select 1 from (
-> select /*+ read_from_storage(tiflash[t]) */ sum(1)
-> from t where d BETWEEN '2023-07-01' and '2023-07-03' group by d
-> ) total;
Empty set (0.03 sec)

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.1.0
Edition: Community
Git Commit Hash: 1a89dec
Git Branch: heads/refs/tags/v6.1.0
UTC Build Time: 2022-06-05 05:09:33
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

@kennedy8312
Copy link

mysql> select * from information_schema.tiflash_replica; -- wait until the replication progress finish
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_ID | REPLICA_COUNT | LOCATION_LABELS | AVAILABLE | PROGRESS |
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| test | t | 102 | 1 | | 1 | 1 |
+--------------+------------+----------+---------------+-----------------+-----------+----------+
1 row in set (0.02 sec)

mysql> select 1 from (
-> select /*+ read_from_storage(tiflash[t]) */ sum(1)
-> from t where d BETWEEN '2023-07-01' and '2023-07-03' group by d
-> ) total;
ERROR 1105 (HY000): other error for mpp stream: Code: 0, e.displayText() = DB::TiFlashException: Different aggregation mode detected, e.what() = DB::TiFlashException,
mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.5.0
Edition: Community
Git Commit Hash: 069631e
Git Branch: heads/refs/tags/v7.5.0
UTC Build Time: 2023-11-24 08:41:10
GoVersion: go1.21.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

@kennedy8312
Copy link

Regression Analysis
The testcase started to fail on v7.3.0.
Start to analyze regression behavior among releases for issue 51362
Version v5.4.0 : Success
Version v6.0.0 : Success
Version v6.1.0 : Success
Version v6.2.0 : Success
Version v6.3.0 : Success
Version v6.4.0 : Success
Version v6.5.0 : Success
Version v6.6.0 : Success
Version v7.0.0 : Success
Version v7.1.0 : Success
Version v7.2.0 : Success
Version v7.3.0 : Failure
Version v7.4.0 : Failure
Version v7.5.0 : Failure
Version v7.6.0 : Failure

@ti-chi-bot ti-chi-bot added the affects-8.1 This bug affects the 8.1.x(LTS) versions. label Apr 9, 2024
@AilinKid AilinKid self-assigned this May 21, 2024
@seiya-annie
Copy link

/found customer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. report/customer Customers have encountered this bug. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug. type/regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants