domain,session: Store and delete internal session in the session pool#34168
domain,session: Store and delete internal session in the session pool#34168ti-chi-bot merged 6 commits intopingcap:masterfrom
Conversation
Signed-off-by: TonsnakeLin <lpbgytong@163.com>
|
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. DetailsReviewer can indicate their review by submitting an approval review. |
|
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/7749ddc1bfe2c87bc2544f20ab34a26dac50ef82 |
|
Is it possible to cover it with a unit test? |
I'll try it |
Signed-off-by: TonsnakeLin <lpbgytong@163.com>
session/session.go
Outdated
| startTS = txnInfo.StartTS | ||
| } | ||
|
|
||
| logutil.BgLogger().Info( |
There was a problem hiding this comment.
This could be changed to DEBUG level.
domain/db_test.go
Outdated
| } | ||
|
|
||
| func TestNormalSessionPool(t *testing.T) { | ||
| lease := 50 * time.Millisecond |
There was a problem hiding this comment.
Increasing the lease maybe could prevent some weird failures.
sticnarf
left a comment
There was a problem hiding this comment.
I have only one small question.
What if some error happens after getInternalSession gets a session from the pool? I find getSnapshotInfoSchema may raise an error.
It seems like a resource leak. But it seems to me that it does not affect calculating the min start TS, right?
|
Yes, I think you find a bug when use getInternalSession to get internal sessions from session pool. It does not affect calculating the min start TS, because the startTS of the session leaked is always 0.
|
Signed-off-by: TonsnakeLin <lpbgytong@163.com>
Signed-off-by: TonsnakeLin <lpbgytong@163.com>
Would you mind giving a quick fix here in this PR? It might not be a real problem before, because the unused session should be GCed by the runtime, but here it is a real leak because it's saved to the map now. |
|
/merge |
|
This pull request has been accepted and is ready to merge. DetailsCommit hash: 5678cc9 |
|
/run-mysql-test |
|
/run-unit-test |
|
/run-mysql-test |
TiDB MergeCI notify
|
I'll fix it later |
Signed-off-by: TonsnakeLin lpbgytong@163.com
What problem does this PR solve?
Issue Number: close #34154
Problem Summary:
What is changed and how it works?
We stored an internal session to the SessionManger and delete it in the function
(s *session) getInternalSession, but not all internal sessions were got from it. We now store an internal session to the SessionManger and delete it from SessionPool'sgetand 'put' methods, so no internal sessions are lost.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.