Skip to content

fix(runaway): ensure DistSQLContext's checker is synchronized with session variables (#61907)#62319

Closed
ti-chi-bot wants to merge 1 commit intopingcap:release-7.5from
ti-chi-bot:cherry-pick-61907-to-release-7.5
Closed

fix(runaway): ensure DistSQLContext's checker is synchronized with session variables (#61907)#62319
ti-chi-bot wants to merge 1 commit intopingcap:release-7.5from
ti-chi-bot:cherry-pick-61907-to-release-7.5

Conversation

@ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #61907

What problem does this PR solve?

Issue Number: close #61899.

What changed and how does it work?

Update GetDistSQLCtx to check and align the RunawayChecker in the cached DistSQL context with the session's current value.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Prepare:

create table t1(a int, b int);
insert into t1 value(rand()*1000, rand()*1000); x 44600

mysql> select count(*) from t1;
+----------+
| count(*) |
+----------+
|    44600 |
+----------+
1 row in set (0.01 sec)

mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 100 QUERY_LIMIT=(RU=10, ACTION=KILL);
Query OK, 0 rows affected (0.06 sec)

mysql> SET RESOURCE GROUP rg1;
Query OK, 0 rows affected (0.00 sec)

Before:

mysql> explain analyze select * from t1 where b > 36;
ERROR 8253 (HY000): Query execution was interrupted, identified as runaway query [RequestUnit = RRU:13.419626, WRU:0.000000, WaitDuration:0s(10)]

mysql> explain analyze select min(a)+10 from t1 where a < 639;
ERROR 8253 (HY000): Query execution was interrupted, identified as runaway query [RequestUnit = RRU:38.330615, WRU:0.000000, WaitDuration:0s(10)]

mysql> explain analyze select * from t1 where b > (select min(a)+3 from t1 where a < 452);
+--------------------------+----------+---------+-----------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+----------+------+
| id                       | estRows  | actRows | task      | access object | execution info                                                                                                                                                                                                                                                                                                                                                                                                                            | operator info                                    | memory   | disk |
+--------------------------+----------+---------+-----------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+----------+------+
| TableReader_36           | 18466.67 | 44437   | root      |               | time:217.3ms, loops:46, RU:78.809008, cop_task: {num: 9, max: 121.4ms, min: 572.6µs, avg: 24.1ms, p95: 121.4ms, max_proc_keys: 17376, p95_proc_keys: 17376, tot_proc: 25.1ms, tot_wait: 370.2µs, copr_cache_hit_ratio: 0.00, build_task_duration: 8.17µs, max_distsql_concurrency: 1}, rpc_info:{Cop:{num_rpc:9, total_time:217.1ms}}                                                                                                     | data:Selection_35                                | 414.5 KB | N/A  |
| └─Selection_35           | 18466.67 | 44437   | cop[tikv] |               | tikv_task:{proc max:8ms, min:0s, avg: 2.78ms, p80:6ms, p95:8ms, iters:79, tasks:9}, scan_detail: {total_process_keys: 44600, total_process_keys_size: 1906316, total_keys: 44609, get_snapshot_time: 199µs, rocksdb: {key_skipped_count: 44600, block: {cache_hit_count: 93}}}, time_detail: {total_process_time: 25.1ms, total_suspend_time: 45.2µs, total_wait_time: 370.2µs, total_kv_read_wall_time: 25ms, tikv_wall_time: 26.2ms}    | gt(test.t1.b, 3)                                 | N/A      | N/A  |
|   └─TableFullScan_34     | 55400.00 | 44600   | cop[tikv] | table:t1      | tikv_task:{proc max:8ms, min:0s, avg: 2.78ms, p80:6ms, p95:8ms, iters:79, tasks:9}                                                                                                                                                                                                                                                                                                                                                        | keep order:false, stats:partial[b:unInitialized] | N/A      | N/A  |
+--------------------------+----------+---------+-----------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+----------+------+
3 rows in set (0.24 sec)

After:

mysql> explain analyze select min(a)+10 from t1 where a < 639;
ERROR 8253 (HY000): Query execution was interrupted, identified as runaway query [RequestUnit = RRU:29.563074, WRU:0.000000, WaitDuration:0s(10)]

mysql> explain analyze select * from t1 where b > 36;
ERROR 8253 (HY000): Query execution was interrupted, identified as runaway query [RequestUnit = RRU:10.572321, WRU:0.000000, WaitDuration:0s(10)]

mysql> explain analyze select * from t1 where b > (select min(a)+3 from t1 where a < 452);
ERROR 8253 (HY000): Query execution was interrupted, identified as runaway query [RequestUnit = RRU:30.184085, WRU:0.000000, WaitDuration:0s(10)]

Release note

Fixed an issue where the evaluating of non-correlated subqueries could cause runaway configuration to become invalid.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels Jul 9, 2025
@ti-chi-bot
Copy link
Member Author

@JmPotato This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 9, 2025
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels Jul 9, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 9, 2025

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be approved by the approvers firstly.
  2. AFTER it has been approved by approvers, please wait for the cherry-pick merging approval from triage owners.
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 9, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign wshwsh12 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 9, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 9, 2025

@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test ce76cbb link true /test unit-test
idc-jenkins-ci-tidb/build ce76cbb link true /test build
idc-jenkins-ci-tidb/check_dev_2 ce76cbb link true /test check-dev2
idc-jenkins-ci-tidb/check_dev ce76cbb link true /test check-dev
idc-jenkins-ci-tidb/mysql-test ce76cbb link true /test mysql-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@JmPotato JmPotato closed this Jul 9, 2025
@JmPotato JmPotato deleted the cherry-pick-61907-to-release-7.5 branch July 9, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/cherry-pick-not-approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants