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

The query results provided by TiDB are unstable #52934

Open
sjyango opened this issue Apr 27, 2024 · 3 comments
Open

The query results provided by TiDB are unstable #52934

sjyango opened this issue Apr 27, 2024 · 3 comments

Comments

@sjyango
Copy link

sjyango commented Apr 27, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE t0 (
  c0 decimal(10, 0) NOT NULL,
  c1 float unsigned zerofill NOT NULL,
  PRIMARY KEY (c0, c1)
);

INSERT INTO t0 VALUES (-2068985011, 0.75245386), (-668435082, 0.19411194), (-500731198, 0.39079505), (0, 0), (0, 0.9938275), (12196703, 970789000), (919009011, 0.28699672), (1069380201, 0.2576304);

SELECT t0.c0 FROM t0 GROUP BY t0.c0, CAST(t0.c1 AS DATE), t0.c0 OR '' HAVING NOT (t0.c0);

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

+----+
| c0 |
+----+
|  0 |
+----+

3. What did you see instead (Required)

The query results provided by TiDB are unstable, and there is a small probability of different results(Result 1 and Result 2) occurring when the same query is executed multiple times.

Result 1:
MySQL> SELECT t0.c0 FROM t0 GROUP BY t0.c0, CAST(t0.c1 AS DATE), t0.c0 OR '' HAVING NOT (t0.c0);
+----+
| c0 |
+----+
|  0 |
+----+
1 row in set (0.002 sec)

Result 2:
MySQL> SELECT t0.c0 FROM t0 GROUP BY t0.c0, CAST(t0.c1 AS DATE), t0.c0 OR '' HAVING NOT (t0.c0);
+----+
| c0 |
+----+
|  0 |
|  0 |
+----+
2 rows in set, 1 warning (0.005 sec)

4. What is your TiDB version? (Required)

MySQL> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.0.0
Edition: Community
Git Commit Hash: 8ba1fa452b1ccdbfb85879ea94b9254aabba2916
Git Branch: HEAD
UTC Build Time: 2024-03-28 14:22:04
GoVersion: go1.21.6
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.002 sec)
@sjyango sjyango added the type/bug This issue is a bug. label Apr 27, 2024
@jebter jebter added the sig/execution SIG execution label Apr 28, 2024
@yibin87
Copy link
Contributor

yibin87 commented Apr 29, 2024

The root cause is tikv's cast decimal as date is not consistent with tidb. If planner generates two-phase agg, then tikv will execute the cast decimal as date, otherwise, tidb will.

@yibin87
Copy link
Contributor

yibin87 commented Apr 29, 2024

/label affects-8.1

@yibin87
Copy link
Contributor

yibin87 commented Apr 29, 2024

/severity major

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants