Skip to content

memory_quota hint doesn't work well with global binding #53834

@0xPoe

Description

@0xPoe

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Start the TiDB cluster: tiup playground v8.1.0
  2. Use sysbench to create a table and insert 100000 rows:
sysbench oltp_insert --table-size=100000 --mysql-db=test --mysql-user=root --mysql-port=4000 --mysql-host=127.0.0.1 prepare
sysbench oltp_insert --table-size=100000 --mysql-db=test --mysql-user=root --mysql-port=4000 --mysql-host=127.0.0.1 run
  1. Try following SQLs:
use test;
create table sbtest2 like sbtest1;
insert into sbtest2 select * from sbtest1;
create table sbtest3 like sbtest1;
  1. Try this SQLs with hint:
replace into  sbtest3 select /*+ memory_quota(2 GB) */ a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000;

create global binding for replace into sbtest3 select a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000 using replace into  sbtest3 select /*+ memory_quota(2 GB) */ a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000;


replace into sbtest3 select  a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000;

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

All queries canceled by memory controller.

3. What did you see instead (Required)

mysql> replace into  sbtest3 select /*+ memory_quota(2 GB) */ a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000;
ERROR 8175 (HY000): Your query has been cancelled due to exceeding the allowed memory limit for a single SQL query. Please try narrowing your query scope or increase the tidb_mem_quota_query limit and try again.[conn=4011851786]

mysql> create global binding for replace into sbtest3 select a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000 using replace into  sbtest3 select /*+ memory_quota(2 GB) */ a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000;
Query OK, 0 rows affected (0.01 sec)

mysql> replace into sbtest3 select  a.* from sbtest1 a, sbtest2 b where a.pad=b.pad  limit 0,10000;
Query OK, 10000 rows affected (0.34 sec)
Records: 10000  Duplicates: 0  Warnings: 0

4. What is your TiDB version? (Required)

v8.1.0

Metadata

Metadata

Assignees

Labels

affects-5.4This bug affects the 5.4.x(LTS) versions.affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.report/customerCustomers have encountered this bug.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions