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

sometimes the stream_agg return wrong results #29554

Closed
ChenPeng2013 opened this issue Nov 8, 2021 · 6 comments · Fixed by #29809
Closed

sometimes the stream_agg return wrong results #29554

ChenPeng2013 opened this issue Nov 8, 2021 · 6 comments · Fixed by #29809
Labels
affects-5.3 This bug affects 5.3.x versions. severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@ChenPeng2013
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test;
source [test.txt](https://github.com/pingcap/tidb/files/7495237/test.txt);

// if you can't reproduce, please execute several times
select /*+ hash_agg() */ count(col1), max(col2), min(col2), count(col2), count(1), count(*) from IDT_MULTI21872 where col2 is not null group by col1, col2;

select /*+ stream_agg() */ count(col1), max(col2), min(col2), count(col2), count(1), count(*) from IDT_MULTI21872 where col2 is not null group by col1, col2;

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

mysql> select /*+ stream_agg() */ count(col1), max(col2), min(col2), count(col2), count(1), count(*) from IDT_MULTI21872 where col2 is not null group by col1, col2;
+-------------+----------------------+----------------------+-------------+----------+----------+
| count(col1) | max(col2)            | min(col2)            | count(col2) | count(1) | count(*) |
+-------------+----------------------+----------------------+-------------+----------+----------+
|           1 |  3483474160408538637 |  3483474160408538637 |           1 |        1 |        1 |
|           1 |  -712285148954991773 |  -712285148954991773 |           1 |        1 |        1 |
...
|           1 | -8957794185274125772 | -8957794185274125772 |           1 |        1 |        1 |
+-------------+----------------------+----------------------+-------------+----------+----------+
103 rows in set (0.00 sec)

3. What did you see instead (Required)

mysql> select /*+ stream_agg() */ count(col1), max(col2), min(col2), count(col2), count(1), count(*) from IDT_MULTI21872 where col2 is not null group by col1, col2;
+----------------------+----------------------+----------------------+-------------+----------+----------+
| count(col1)          | max(col2)            | min(col2)            | count(col2) | count(1) | count(*) |
+----------------------+----------------------+----------------------+-------------+----------+----------+
| -4522959929954248182 | -4522959929954248182 | -4522959929954248182 |           1 |        1 |        1 |
|  8785184831897790124 |  8785184831897790124 |  8785184831897790124 |           1 |        1 |        1 |
...
|  7320670807156461105 |  7320670807156461105 |  7320670807156461105 |           1 |        1 |        1 |
+----------------------+----------------------+----------------------+-------------+----------+----------+
103 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

Release Version: v5.4.0-alpha-45-ge98d58757
Edition: Community
Git Commit Hash: e98d587577d66e358c50edaa39f08852a0b3314d
Git Branch: master
UTC Build Time: 2021-11-08 06:43:19
GoVersion: go1.16.5
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@ChenPeng2013 ChenPeng2013 added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/critical affects-5.3 This bug affects 5.3.x versions. labels Nov 8, 2021
@guo-shaoge
Copy link
Collaborator

After discuss with @tiancaiamao , it's better to revert #29232 and #29064 in 5.3 for safty.

@winoros
Copy link
Member

winoros commented Nov 8, 2021

@guo-shaoge It's this solvable? i.e. Keep the optimization also solve the issue.

@guo-shaoge
Copy link
Collaborator

@guo-shaoge It's this solvable? i.e. Keep the optimization also solve the issue.

Guess we can solve it by filtering duplicated column when reset chunk.allocator. However, there may be performance loss.

@tiancaiamao
Copy link
Contributor

@guo-shaoge It's this solvable? i.e. Keep the optimization also solve the issue.

Of course it should be! In the master branch we will find out the solution.

@fuzhe1989
Copy link
Contributor

fuzhe1989 commented Nov 15, 2021

Also affected pingcap/tiflash#3406.

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 This bug affects 5.3.x versions. severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
5 participants