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

server: make call to ReleaseConnID idempotent. #45676

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

pingyu
Copy link
Contributor

@pingyu pingyu commented Jul 29, 2023

What problem does this PR solve?

Issue Number: close #45675

Problem Summary: Failed to release 32bits connection ID

There are two calls to release for every connection ID. So the pool is unexpected full.

(dlv) bt
0  0x00000000041129aa in github.com/pingcap/tidb/util/globalconn.(*LockFreeCircularPool).Put
   at ./util/globalconn/pool.go:219
1  0x0000000004111d31 in github.com/pingcap/tidb/util/globalconn.(*GlobalAllocator).Release
   at ./util/globalconn/globalconn.go:307
2  0x0000000004c36e18 in github.com/pingcap/tidb/domain.(*Domain).ReleaseConnID
   at ./domain/domain.go:2859
3  0x0000000004c36e18 in github.com/pingcap/tidb/server.closeConn
   at ./server/conn.go:340
4  0x0000000004c36d69 in github.com/pingcap/tidb/server.(*clientConn).Close
   at ./server/conn.go:335
5  0x0000000004c3d58f in github.com/pingcap/tidb/server.(*clientConn).Run.func1
   at ./server/conn.go:967
6  0x0000000004c3cf7c in github.com/pingcap/tidb/server.(*clientConn).Run
   at ./server/conn.go:1030
7  0x0000000004c74867 in github.com/pingcap/tidb/server.(*Server).onConn
   at ./server/server.go:662
8  0x0000000004c7324a in github.com/pingcap/tidb/server.(*Server).startNetworkListener.func1
   at ./server/server.go:478
9  0x0000000001ad5d21 in runtime.goexit
   at /data/nvme0n1/home/pingyu/opt/go1.20.4/src/runtime/asm_amd64.s:1598
(dlv) bt
0  0x00000000041129aa in github.com/pingcap/tidb/util/globalconn.(*LockFreeCircularPool).Put
   at ./util/globalconn/pool.go:219
1  0x0000000004111d31 in github.com/pingcap/tidb/util/globalconn.(*GlobalAllocator).Release
   at ./util/globalconn/globalconn.go:307
2  0x0000000004c36e18 in github.com/pingcap/tidb/domain.(*Domain).ReleaseConnID
   at ./domain/domain.go:2859
3  0x0000000004c36e18 in github.com/pingcap/tidb/server.closeConn
   at ./server/conn.go:340
4  0x0000000004c36d69 in github.com/pingcap/tidb/server.(*clientConn).Close
   at ./server/conn.go:335
5  0x0000000004c75caf in github.com/pingcap/tidb/server.(*Server).onConn.func3
   at ./server/server.go:639
6  0x0000000004c74950 in github.com/pingcap/tidb/server.(*Server).onConn
   at ./server/server.go:678
7  0x0000000004c7324a in github.com/pingcap/tidb/server.(*Server).startNetworkListener.func1
   at ./server/server.go:478
8  0x0000000001ad5d21 in runtime.goexit
   at /data/nvme0n1/home/pingyu/opt/go1.20.4/src/runtime/asm_amd64.s:1598

What is changed and how it works?

Make release connection ID idempotent by set clientClient.connectionID to 0 after connection ID is released.

The duplicated close connection may need to be fixed later.
But as there are even more calls to clientConn.Close and closeConn, especially on handling errors, this PR prefer to make closeConn idempotent to ensue correctness.

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: Ping Yu <yuping@pingcap.com>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 29, 2023
@tiprow
Copy link

tiprow bot commented Jul 29, 2023

Hi @pingyu. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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/test-infra repository.

@pingyu
Copy link
Contributor Author

pingyu commented Jul 29, 2023

/run-e2e-test
/run-integration-jdbc-test

@pingyu
Copy link
Contributor Author

pingyu commented Jul 29, 2023

/run-jdbc-test

@codecov
Copy link

codecov bot commented Jul 29, 2023

Codecov Report

Merging #45676 (399aad7) into master (f4f78a1) will increase coverage by 0.2110%.
Report is 12 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #45676        +/-   ##
================================================
+ Coverage   73.2198%   73.4308%   +0.2110%     
================================================
  Files          1265       1269         +4     
  Lines        389829     392851      +3022     
================================================
+ Hits         285432     288474      +3042     
+ Misses        86089      86079        -10     
+ Partials      18308      18298        -10     
Flag Coverage Δ
integration 78.1388% <ø> (?)
unit 73.4227% <100.0000%> (+0.2029%) ⬆️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0417% <ø> (ø)
br 52.3734% <ø> (+0.2698%) ⬆️

@purelind
Copy link
Contributor

/test ?

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 29, 2023

@purelind: The following commands are available to trigger required jobs:

  • /test build
  • /test canary-scan-security
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-br-integration-test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-ddl-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-mysql-connector-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pull-notify-when-compatibility-sections-changed

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test

In response to this:

/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/test-infra repository.

@tiprow
Copy link

tiprow bot commented Jul 29, 2023

@purelind: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/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/test-infra repository.

@pingyu
Copy link
Contributor Author

pingyu commented Jul 29, 2023

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Jul 29, 2023
@pingyu
Copy link
Contributor Author

pingyu commented Jul 29, 2023

/test pull-integration-jdbc-test

@tiprow
Copy link

tiprow bot commented Jul 29, 2023

@pingyu: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test pull-integration-jdbc-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/test-infra repository.

@pingyu
Copy link
Contributor Author

pingyu commented Jul 29, 2023

The failure of pull-integration-jdbc-test is the issue of test case, and will be fixed by https://github.com/pingcap/tidb-test/pull/2191.

@pingyu
Copy link
Contributor Author

pingyu commented Jul 29, 2023

/cc @breezewish @xuyifangreeneyes

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 29, 2023

@pingyu: GitHub didn't allow me to request PR reviews from the following users: xuyifangreeneyes.

Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @breezewish @xuyifangreeneyes

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot requested a review from breezewish July 29, 2023 09:57
@pingyu
Copy link
Contributor Author

pingyu commented Jul 29, 2023

/cc @breezewish @xuyifangreeneyes

PTAL, thanks~

@pingyu
Copy link
Contributor Author

pingyu commented Jul 30, 2023

/test pull-integration-jdbc-test

@tiprow
Copy link

tiprow bot commented Jul 30, 2023

@pingyu: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test pull-integration-jdbc-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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jul 31, 2023
@pingyu
Copy link
Contributor Author

pingyu commented Jul 31, 2023

/check-issue-triage-complete

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 31, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: breezewish, tangenta

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [breezewish,tangenta]

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 lgtm label Jul 31, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 31, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 31, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-07-31 02:37:00.027518613 +0000 UTC m=+66503.969867143: ☑️ agreed by tangenta.
  • 2023-07-31 10:46:21.604727925 +0000 UTC m=+95865.547076455: ☑️ agreed by breezewish.

@pingyu
Copy link
Contributor Author

pingyu commented Jul 31, 2023

/retest

1 similar comment
@pingyu
Copy link
Contributor Author

pingyu commented Jul 31, 2023

/retest

@ti-chi-bot ti-chi-bot bot merged commit 35e654e into pingcap:master Jul 31, 2023
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to release 32bits connection ID
4 participants