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

return wrong results when accessing partition tables with tablesample #52282

Closed
qw4990 opened this issue Apr 1, 2024 · 4 comments · Fixed by #52405
Closed

return wrong results when accessing partition tables with tablesample #52282

qw4990 opened this issue Apr 1, 2024 · 4 comments · Fixed by #52405
Assignees
Labels

Comments

@qw4990
Copy link
Contributor

qw4990 commented Apr 1, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t (a int, b varchar(255), primary key (a)) partition by hash(a) partitions 2;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t values (1, '1'), (2, '2'), (3, '3');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> set @@tidb_partition_prune_mode='static';
Query OK, 0 rows affected (0.00 sec)

mysql> select * from t tablesample regions();
+---+------+
| a | b    |
+---+------+
| 2 | 2    |
| 1 | 1    |
| 2 | 2    |
| 1 | 1    |
+---+------+
4 rows in set (0.00 sec)

mysql> set @@tidb_partition_prune_mode='dynamic';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> select * from t tablesample regions();
+---+------+
| a | b    |
+---+------+
| 2 | 2    |
| 1 | 1    |
+---+------+
2 rows in set (0.00 sec)

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

Return the same result no matter whether it is dynamic or static node

3. What did you see instead (Required)

Dynamic and static mode return different results

4. What is your TiDB version? (Required)

Master

@qw4990 qw4990 added type/bug This issue is a bug. sig/sql-infra SIG: SQL Infra severity/major labels Apr 1, 2024
@lance6716 lance6716 added the component/dumpling This is related to Dumpling of TiDB. label Apr 1, 2024
@lance6716
Copy link
Contributor

dumpling uses the TABLESAMPLE feature, please help to explain which is the wrong result and what's the trigger condition

@kennedy8312
Copy link

/type regression

@kennedy8312
Copy link

Regression Analysis
The testcase started to show wrong result from v8.0.0.
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 : Success
Version v7.4.0 : Success
Version v7.5.0 : Success
Version v7.6.0 : Success
Version v8.0.0 : Failure
Version nightly : Failure

@kennedy8312
Copy link

kennedy8312 commented Apr 3, 2024

Regression Analysis
PR caused this regression: #51903

first bad commit: [43cf9a2] planner: apply rule_partition_pruning when optimizing CTE under static mode (#51903) (#52148)

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

Successfully merging a pull request may close this issue.

5 participants