pingcap / pingcap/tidb

resource group hint cannot work well in prepare/excute statement

Open
#51,011 0 comments 0 reactions 0 assignees View on GitHub
affects-8.1 affects-8.5 component/pd may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 severity/major 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)

```
create user 'user1';
GRANT ALL PRIVILEGES ON *.* TO 'user1'@'%';
create resource group if not exists rg1 RU_PER_SEC=10000000;
create resource group if not exists rp RU_PER_SEC=2000000;
alter user 'user1' resource group rg1;
```

change sysbench `oltp_common.lua` to add a hint.
```
local stmt_defs = {
point_selects = {
"SELECT /*+ RESOURCE_GROUP(tp) */ c FROM sbtest%u WHERE id=?",
t.INT},
```
run workload

```
sysbench --mysql-user=user1 --mysql-host=127.0.0.1 --mysql-port=4000 --table-size=10000 --time=360 oltp_point_select --tables=2 prepare
```

### 2. What did you expect to see? (Required)
the expected resource group `tp`.

### 3. What did you see instead (Required)

the resource group almos in `rg1`.

![image](https://github.com/pingcap/tidb/assets/6428910/65d72c90-230b-4264-bf21-a322a34ef10a)

### 4. What is your TiDB version? (Required)

above 7.6

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior with the SQL setup, the RESOURCE_GROUP hint in sysbench's oltp_common.lua, and the prepare command shown in the report. Compare the selected resource group for prepared versus non-prepared execution, then trace the relevant TiDB resource-group handling. Done means the prepared statement uses the hinted group tp rather than the user's default group rg1.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.