Bug #112011 | RESOURCE GROUP hint fails when used within a prepared statement | ||
---|---|---|---|
Submitted: | 9 Aug 2023 12:06 | Modified: | 10 Aug 2023 13:19 |
Reporter: | Iwo P | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Prepared statements | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[9 Aug 2023 12:06]
Iwo P
[9 Aug 2023 13:04]
MySQL Verification Team
Hi Mr. P, Thank you for your bug report. However, you have set your OS to "Any", while resource groups are supported only on Linux. You have also set the "Category" to "MySQL Server: Prepared statements". However, in SQL your test case works just fine in SQL. What does not work are prepared statements in our Connector/J. Hence, we have to ask you do still think that this is a report that is applicable to all operating systems and that it is a bug in the server. We are waiting on your response.
[10 Aug 2023 13:08]
Dmitry Lenev
Hello! Actually, it is easy to reproduce this problem on Linux without involving Connector and Java at all. Here is the simple test case for MTR framework which demostrates the problem using MySQL's PREPARE syntax. I am sure the same can be reproduced using MySQL C API. CREATE RESOURCE GROUP r1 TYPE=USER VCPU=0,1; --echo # The below query should see itself as executed in 'r1' resource group in the P_S.THREADS table SELECT /*+ RESOURCE_GROUP(r1) */ processlist_info, resource_group FROM performance_schema.threads WHERE processlist_id = connection_id(); # Returns: # processlist_info resource_group # SELECT /*+ RESOURCE_GROUP(r1) */ processlist_info, resource_group FROM performance_schema.threads WHERE processlist_id = connection_id() r1 --echo # Make prepared statement from the same query. PREPARE stmt1 FROM 'SELECT /*+ RESOURCE_GROUP(r1) */ processlist_info, resource_group FROM performance_schema.threads WHERE processlist_id = connection_id()'; --echo # The expectation is that execution of prepared statement will use 'r1' resource group as well. But it is not!!! EXECUTE stmt1; # Returns: # processlist_info resource_group # EXECUTE stmt1 USR_default DEALLOCATE PREPARE stmt1;
[10 Aug 2023 13:19]
MySQL Verification Team
Thank you Mr. Lenev, We were able to repeat your test case. Hence, this is now a verified bug report.
[16 Aug 2023 17:29]
Dmitry Lenev
Hello! Here is a straightforward patch against 8.0.34 version of MySQL server which solves the problem.
[16 Aug 2023 17:29]
Dmitry Lenev
Straightfoward fix against MySQL Server 8.0.34 (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: ps-8871-bug112011-contrib.patch (text/x-patch), 14.08 KiB.
[17 Aug 2023 12:21]
MySQL Verification Team
Thank you, Mr. Lenev, This is very kind of you. We will welcome any future contribution from you, since we have a feeling that you know some parts of MySQL source code.