Skip to content

domain,session: Store and delete internal session in the session pool#34168

Merged
ti-chi-bot merged 6 commits intopingcap:masterfrom
TonsnakeLin:dev-debug-innerTxn
Apr 29, 2022
Merged

domain,session: Store and delete internal session in the session pool#34168
ti-chi-bot merged 6 commits intopingcap:masterfrom
TonsnakeLin:dev-debug-innerTxn

Conversation

@TonsnakeLin
Copy link
Contributor

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's get and 'put' methods, so no internal sessions are lost.

Check List

Tests

  • Unit test
  • Integration test
  • 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.

None

Signed-off-by: TonsnakeLin <lpbgytong@163.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • cfzjywxk
  • sticnarf

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 do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 22, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Apr 22, 2022

@TonsnakeLin
Copy link
Contributor Author

@sticnarf
Copy link
Contributor

Is it possible to cover it with a unit test?

@TonsnakeLin
Copy link
Contributor Author

Is it possible to cover it with a unit test?

I'll try it

@hawkingrei hawkingrei requested a review from lcwangchao April 23, 2022 08:04
Signed-off-by: TonsnakeLin <lpbgytong@163.com>
@ti-chi-bot ti-chi-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 Apr 27, 2022
@TonsnakeLin
Copy link
Contributor Author

startTS = txnInfo.StartTS
}

logutil.BgLogger().Info(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be changed to DEBUG level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

func TestNormalSessionPool(t *testing.T) {
lease := 50 * time.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increasing the lease maybe could prevent some weird failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@TonsnakeLin
Copy link
Contributor Author

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.

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?

Copy link
Contributor

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have more comments except those from @cfzjywxk

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 28, 2022
Signed-off-by: TonsnakeLin <lpbgytong@163.com>
Signed-off-by: TonsnakeLin <lpbgytong@163.com>
@TonsnakeLin TonsnakeLin requested a review from cfzjywxk April 28, 2022 06:23
@sticnarf
Copy link
Contributor

sticnarf commented Apr 28, 2022

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.

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.

@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 29, 2022
@cfzjywxk
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

DetailsCommit hash: 5678cc9

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 29, 2022
@TonsnakeLin
Copy link
Contributor Author

/run-mysql-test

@TonsnakeLin
Copy link
Contributor Author

/run-unit-test

@TonsnakeLin
Copy link
Contributor Author

/run-mysql-test

@ti-chi-bot ti-chi-bot merged commit 5b6ffa7 into pingcap:master Apr 29, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Apr 29, 2022

TiDB MergeCI notify

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci/integration-cdc-test 🟢 all 34 tests passed 32 min Existing passed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 11 tests passed 17 min Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 16 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 12 tests passed 12 min Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 10 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 9 min 1 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 8 min 53 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 5 min 43 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 4 min 57 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

@TonsnakeLin
Copy link
Contributor Author

but here it is a real leak because it's saved to the map no

I'll fix it later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note-none Denotes a PR that doesn't merit a release note. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

internal txn failed due to do gc

5 participants