Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: global memory controller should not kill session whose mem less than limit_sess_min_size (#42803) #42852

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #42803

What problem does this PR solve?

Issue Number:
close #42662
close #42664

Problem Summary:
As the description mentioned here:
#42662 (comment)

What is changed and how it works?

  1. Reset NeekKill flag even error is thrown during the planner phase or executor.Open phase
  2. Do not kill the session whose memory usage is less than tidb_server_memory_limit_sess_min_size

Check List

Tests

  • Unit test
  • Integration test

If we run the same test on master branch, the following error will be thrown:

    testkit.go:157: 
        	Error Trace:	/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/testkit/testkit.go:157
        	            				/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/testkit/testkit.go:150
        	            				/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/executor_test.go:6521
        	Error:      	Received unexpected error:
        	            	Out Of Memory Quota![conn=12345]
        	            	github.com/pingcap/tidb/executor.(*ExecStmt).openExecutor.func1
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/adapter.go:1188
        	            	runtime.gopanic
        	            		/Users/xuhuaiyu/.gvm/gos/go1.20/src/runtime/panic.go:884
        	            	github.com/pingcap/tidb/util/memory.(*PanicOnExceed).Action
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/memory/action.go:149
        	            	github.com/pingcap/tidb/util/memory.(*Tracker).Consume.func2
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/memory/tracker.go:450
        	            	github.com/pingcap/tidb/util/memory.(*Tracker).Consume
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/util/memory/tracker.go:462
        	            	github.com/pingcap/tidb/executor.(*HashAggExec).initForParallelExec
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/aggregate.go:395
        	            	github.com/pingcap/tidb/executor.(*HashAggExec).Open
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/aggregate.go:321
        	            	github.com/pingcap/tidb/executor.(*ExecStmt).openExecutor
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/adapter.go:1192
        	            	github.com/pingcap/tidb/executor.(*ExecStmt).Exec
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/adapter.go:527
        	            	github.com/pingcap/tidb/session.runStmt
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/session/session.go:2343
        	            	github.com/pingcap/tidb/session.(*session).ExecuteStmt
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/session/session.go:2200
        	            	github.com/pingcap/tidb/testkit.(*TestKit).ExecWithContext
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/testkit/testkit.go:325
        	            	github.com/pingcap/tidb/testkit.(*TestKit).MustQueryWithContext
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/testkit/testkit.go:156
        	            	github.com/pingcap/tidb/testkit.(*TestKit).MustQuery
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/testkit/testkit.go:150
        	            	github.com/pingcap/tidb/executor_test.TestIssue42662
        	            		/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/executor_test.go:6521
        	            	testing.tRunner
        	            		/Users/xuhuaiyu/.gvm/gos/go1.20/src/testing/testing.go:1576
        	            	runtime.goexit
        	            		/Users/xuhuaiyu/.gvm/gos/go1.20/src/runtime/asm_amd64.s:1598
        	Test:       	TestIssue42662
        	Messages:   	sql:select count(*) from t1, args:[]

  • Manual test (add detailed scripts or steps below)
  • 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.

Fix the problem that global memory controller kill the sqls whose memory usage are less than tidb_server_memory_limit_sess_min_size defined.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member Author

ti-chi-bot commented Apr 7, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • chrysan
  • wshwsh12

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.

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 Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/cherry-pick-not-approved sig/execution SIG execution size/L Denotes a PR that changes 100-499 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 Apr 7, 2023
@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Apr 7, 2023
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 10, 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 Apr 10, 2023
@XuHuaiyu
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member Author

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

Commit hash: 44c1f94

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 10, 2023
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot merged commit 0105222 into pingcap:release-6.5 Apr 10, 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 Apr 18, 2023
@VelocityLight VelocityLight added do-not-merge/cherry-pick-not-approved and removed cherry-pick-approved Cherry pick PR approved by release team. labels Apr 21, 2023
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 release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/execution SIG execution size/L Denotes a PR that changes 100-499 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