-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Data inconsistency when tpcc check #39266
Comments
Does the result right when using TiKV replica only? |
yes. it right when using single tikv or tiflash with control of the var tidb_isolation_read_engiens |
@breezewish Please add troubleshooting information |
A minimal reproduce SQL is: SELECT
ol_w_id,
ol_d_id,
ol_o_id,
count(*) order_line_count
FROM
order_line
WHERE
ol_w_id = 7
GROUP BY
ol_w_id,
ol_d_id,
ol_o_id
ORDER by
ol_w_id,
ol_d_id,
ol_o_id; When Isolation Engine = TiKV, we will discover this row in the result set (which is correct):
When using TiFlash Coprocessor, this row becomes incorrect result:
|
I think the plan is correct here. So I remove the |
Optimizer should not push the streamAgg down to the tiflash when plan contains group by key, as tiflash doesn't implement the related function for streamAgg. So, optimizer should follow this agreement and tiflash may need to raise error when it receives inappropriate streamAgg. |
I can reproduce the plan with the following query: create table foo(a int, b int, c int, d int, primary key(a,b,c,d));
alter table foo set tiflash replica 1;
insert into foo values(1,2,3,1),(1,2,3,6),(1,2,3,5),(1,2,3,2),(1,2,3,4),(1,2,3,7),(1,2,3,3),(1,2,3,0);
set @@tidb_allow_mpp=off;
explain select a,b,c,count(*) from foo group by a,b,c order by a,b,c;
+------------------------------+---------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------------+---------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_33 | 6.40 | root | | test.foo.a, test.foo.b, test.foo.c, Column#5 |
| └─StreamAgg_38 | 6.40 | root | | group by:test.foo.a, test.foo.b, test.foo.c, funcs:count(Column#18)->Column#5, funcs:firstrow(test.foo.a)->test.foo.a, funcs:firstrow(test.foo.b)->test.foo.b, funcs:firstrow(test.foo.c)->test.foo.c |
| └─TableReader_39 | 6.40 | root | | data:StreamAgg_34 |
| └─StreamAgg_34 | 6.40 | cop[tiflash] | | group by:test.foo.a, test.foo.b, test.foo.c, funcs:count(1)->Column#18 |
| └─TableFullScan_24 | 8.00 | cop[tiflash] | table:foo | keep order:true, stats:pseudo |
+------------------------------+---------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
5 rows in set (0.00 sec) We will disable the generation of streamagg on tiflash. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
tpcc 100 warehouse data prepare, set tiflash replica , run some time. Then run the follow sql
The plan is
2. What did you expect to see? (Required)
empty set
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
Release Version: v6.5.0-alpha
Edition: Community
Git Commit Hash: 3bcd5a8
Git Branch: heads/refs/tags/v6.5.0-alpha
UTC Build Time: 2022-11-19 11:13:51
GoVersion: go1.19.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
The text was updated successfully, but these errors were encountered: