Skip to content

session: fix processInfo time when using driver to prepare and execute query (#41151)#41249

Merged
ti-chi-bot merged 1 commit intopingcap:release-6.5from
ti-chi-bot:cherry-pick-41151-to-release-6.5
Feb 17, 2023
Merged

session: fix processInfo time when using driver to prepare and execute query (#41151)#41249
ti-chi-bot merged 1 commit intopingcap:release-6.5from
ti-chi-bot:cherry-pick-41151-to-release-6.5

Conversation

@ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #41151

What problem does this PR solve?

Issue Number: close #41057

Problem Summary:
globalMemoryControl use sql start time to check whether a sql is finished. If the time is not updated, the killing will never finish.

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  1. Use go-sql-driver to prapare sql select sleep(?)
  2. execute using args 10
  3. Sleep 10s in test
  4. Loop Step 2-3, and show processlists
tidb> show processlist;
+---------------+------+-----------------+------+---------+------+------------+------------------+
| Id            | User | Host            | db   | Command | Time | State      | Info             |
+---------------+------+-----------------+------+---------+------+------------+------------------+
| 2199023255955 | root | 127.0.0.1:33122 | NULL | Query   |    0 | autocommit | show processlist |
| 2199023255957 | root | 127.0.0.1:53912 | test | Sleep   |   19 | autocommit | NULL             |
+---------------+------+-----------------+------+---------+------+------------+------------------+
2 rows in set (0.001 sec)

tidb> show processlist;
+---------------+------+-----------------+------+---------+------+------------+------------------+
| Id            | User | Host            | db   | Command | Time | State      | Info             |
+---------------+------+-----------------+------+---------+------+------------+------------------+
| 2199023255955 | root | 127.0.0.1:33122 | NULL | Query   |    0 | autocommit | show processlist |
| 2199023255957 | root | 127.0.0.1:53912 | test | Execute |    0 | autocommit | NULL             |
+---------------+------+-----------------+------+---------+------+------------+------------------+
2 rows in set (0.001 sec)

We can see the Time have been reset.

Manual test 2:
Before the pr, killing is not finished.

[2023/02/09 14:04:06.388 +08:00] [WARN] [servermemorylimit.go:126] ["global memory controller tries to kill the top1 memory consumer"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] [tidb_server_memory_limit=536870912] ["heap inuse"=5
76815104] ["sql memory usage"=377011523]
[2023/02/09 14:04:06.389 +08:00] [WARN] [tracker.go:458] ["global memory controller, NeedKill signal is received successfully"] [connID=3464673289308209561]
[2023/02/09 14:04:11.485 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 5s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=0]
[2023/02/09 14:04:16.585 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 10s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=33506376]
[2023/02/09 14:04:21.684 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 15s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=2789854714]
[2023/02/09 14:04:26.764 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 20s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=4554466769]
[2023/02/09 14:04:32.023 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 25s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=4554466769]
[2023/02/09 14:04:37.287 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 30s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=5317908437]
[2023/02/09 14:04:42.385 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 35s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=6715429525]
[2023/02/09 14:04:47.386 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 40s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=7924455893]
[2023/02/09 14:04:52.534 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 46s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=8986996949]
[2023/02/09 14:04:57.612 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 51s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=10132238165]
[2023/02/09 14:05:02.704 +08:00] [WARN] [servermemorylimit.go:96] ["global memory controller failed to kill the top-consumer in 56s"] [connID=3464673289308209561] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] ["sql memory usage"=11226425045]

After this pr, can cancel the running sql.

[2023/02/09 14:11:33.960 +08:00] [WARN] [servermemorylimit.go:126] ["global memory controller tries to kill the top1 memory consumer"] [connID=4469145331002507667] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] [tidb_server_memory_limit=536870912] ["heap inuse"=562315264] ["sql memory usage"=388879163]
[2023/02/09 14:11:33.979 +08:00] [WARN] [tracker.go:458] ["global memory controller, NeedKill signal is received successfully"] [connID=4469145331002507667]
[2023/02/09 14:11:34.092 +08:00] [WARN] [servermemorylimit.go:112] ["global memory controller killed the top1 memory consumer successfully"]
[2023/02/09 14:11:44.574 +08:00] [WARN] [servermemorylimit.go:126] ["global memory controller tries to kill the top1 memory consumer"] [connID=4469145331002507667] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] [tidb_server_memory_limit=536870912] ["heap inuse"=664477696] ["sql memory usage"=450551538]
[2023/02/09 14:11:44.576 +08:00] [WARN] [tracker.go:458] ["global memory controller, NeedKill signal is received successfully"] [connID=4469145331002507667]
[2023/02/09 14:11:44.676 +08:00] [WARN] [servermemorylimit.go:112] ["global memory controller killed the top1 memory consumer successfully"]
[2023/02/09 14:11:55.164 +08:00] [WARN] [servermemorylimit.go:126] ["global memory controller tries to kill the top1 memory consumer"] [connID=4469145331002507667] ["sql digest"=620e7d8f9d39e8d05c0d44a1ac5d1b480ba12174de9fa330e1a95e8aee27c081] ["sql text"=] [tidb_server_memory_limit=536870912] ["heap inuse"=553074688] ["sql memory usage"=380063432]
[2023/02/09 14:11:55.164 +08:00] [WARN] [tracker.go:458] ["global memory controller, NeedKill signal is received successfully"] [connID=4469145331002507667]
[2023/02/09 14:11:55.274 +08:00] [WARN] [servermemorylimit.go:112] ["global memory controller killed the top1 memory consumer successfully"]
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Member Author

ti-chi-bot commented Feb 9, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • XuHuaiyu
  • guo-shaoge

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Details

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/cherry-pick-not-approved size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/bugfix This PR fixes a bug. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Feb 9, 2023
@wuhuizuo
Copy link
Contributor

/hold high priority for trunk branch

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 10, 2023
@ti-chi-bot
Copy link
Member Author

/unhold

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 10, 2023
@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Feb 16, 2023
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 16, 2023
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 16, 2023
@wshwsh12
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member Author

This pull request has been accepted and is ready to merge.

DetailsCommit hash: b0e4508

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 16, 2023
@wshwsh12
Copy link
Contributor

/retest

@ti-chi-bot ti-chi-bot merged commit 0991a0b into pingcap:release-6.5 Feb 17, 2023
@VelocityLight VelocityLight added do-not-merge/cherry-pick-not-approved cherry-pick-approved Cherry pick PR approved by release team. and removed cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/cherry-pick-not-approved labels Mar 13, 2023
@ti-chi-bot ti-chi-bot deleted the cherry-pick-41151-to-release-6.5 branch April 15, 2025 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-approved Cherry pick PR approved by release team. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants