Skip to content

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

Merged
ti-chi-bot[bot] merged 1 commit intopingcap:release-8.5from
ti-chi-bot:cherry-pick-61907-to-release-8.5
Jul 8, 2025
Merged

fix(runaway): ensure DistSQLContext's checker is synchronized with session variables (#61907)#62220
ti-chi-bot[bot] merged 1 commit intopingcap:release-8.5from
ti-chi-bot:cherry-pick-61907-to-release-8.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.

…ssion variables

Signed-off-by: JmPotato <github@ipotato.me>
@ti-chi-bot ti-chi-bot added 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-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Jul 4, 2025
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 4, 2025
@codecov
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-8.5@2ba910c). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.5     #62220   +/-   ##
================================================
  Coverage               ?   57.7295%           
================================================
  Files                  ?       1771           
  Lines                  ?     631476           
  Branches               ?          0           
================================================
  Hits                   ?     364548           
  Misses                 ?     242299           
  Partials               ?      24629           
Flag Coverage Δ
integration 38.4083% <100.0000%> (?)
unit 72.6658% <100.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9278% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 63.2038% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lhy1024
Copy link
Contributor

lhy1024 commented Jul 4, 2025

/test unit-test

@tiprow
Copy link

tiprow bot commented Jul 4, 2025

@lhy1024: No presubmit jobs available for pingcap/tidb@release-8.5

Details

In response to this:

/test unit-test

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.

@JmPotato
Copy link
Member

JmPotato commented Jul 7, 2025

/test unit-test

@tiprow
Copy link

tiprow bot commented Jul 7, 2025

@JmPotato: No presubmit jobs available for pingcap/tidb@release-8.5

Details

In response to this:

/test unit-test

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 ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jul 7, 2025
@JmPotato
Copy link
Member

JmPotato commented Jul 8, 2025

/test unit-test

@tiprow
Copy link

tiprow bot commented Jul 8, 2025

@JmPotato: No presubmit jobs available for pingcap/tidb@release-8.5

Details

In response to this:

/test unit-test

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 ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 8, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 8, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-07-04 09:08:28.12417971 +0000 UTC m=+1645160.847358696: ☑️ agreed by JmPotato.
  • 2025-07-08 06:53:30.321115961 +0000 UTC m=+1982663.044294943: ☑️ agreed by rleungx.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 8, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JmPotato, rleungx, xhebox

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

The pull request process is described 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 the approved label Jul 8, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 8, 2025

@ti-chi-bot: The following test 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 dda5c5b link unknown /test unit-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
Copy link
Member

JmPotato commented Jul 8, 2025

/test unit-test

@tiprow
Copy link

tiprow bot commented Jul 8, 2025

@JmPotato: No presubmit jobs available for pingcap/tidb@release-8.5

Details

In response to this:

/test unit-test

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 ti-chi-bot bot merged commit 71459c7 into pingcap:release-8.5 Jul 8, 2025
17 of 18 checks passed
@JmPotato JmPotato deleted the cherry-pick-61907-to-release-8.5 branch July 8, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. lgtm 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-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants