pingcap / pingcap/tidb

Inconsistent result after disabling some optimization rules

Open
#57,861 0 comments 0 reactions 0 assignees View on GitHub
severity/major sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
```sql
set @@session.`tidb_partition_prune_mode`='static';
create table `t0` (`id` int primary key,`balance` decimal(10,2),`balance2` decimal(10,2) generated always as(-`balance`) virtual,`created_at` timestamp) partition by hash (`id`) partitions 8;
insert into `t0` (`id`,`balance`,`created_at`) values (1,100,'2021-06-17 22:35:20');
delete from mysql.opt_rule_blacklist;
admin reload opt_rule_blacklist;
select * from `t0` where `id`=1 for update;
INSERT INTO mysql.opt_rule_blacklist VALUES("predicate_push_down"),("partition_processor");
ADMIN reload opt_rule_blacklist;
select * from `t0` where `id`=1 for update;
```

### 2. What did you expect to see? (Required)
Queries return same result

### 3. What did you see instead (Required)
```sql
mysql> delete from mysql.opt_rule_blacklist;
Query OK, 0 rows affected (0.00 sec)

mysql> admin reload opt_rule_blacklist;
Query OK, 0 rows affected (0.01 sec)

mysql> select * from `t0` where `id`=1 for update;
+----+---------+----------+---------------------+
| id | balance | balance2 | created_at |
+----+---------+----------+---------------------+
| 1 | 100.00 | -100.00 | 2021-06-17 22:35:20 |
+----+---------+----------+---------------------+
1 row in set (0.00 sec)

mysql> INSERT INTO mysql.opt_rule_blacklist VALUES("predicate_push_down"),("partition_processor");
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> ADMIN reload opt_rule_blacklist;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from `t0` where `id`=1 for update;
Empty set (0.00 sec)
```

### 4. What is your TiDB version? (Required)
```sql
Release Version: v8.5.0-alpha-79-g426ce3e570
Edition: Community
Git Commit Hash: 426ce3e57069afbd8f061d7ae39c79d3f9e2ff5d
Git Branch: master
UTC Build Time: 2024-11-09 12:25:03
GoVersion: go1.23.0
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied SQL reproduction with and without predicate_push_down and partition_processor in mysql.opt_rule_blacklist, then trace the optimizer handling of partition pruning and predicate pushdown. Done means both queries return the same row, with a regression test covering the blacklist changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.