-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: refine the connection counter logic (#54546) #54612
server: refine the connection counter logic (#54546) #54612
Conversation
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: easonn7, xhebox, YangKeao 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:
Approvers can indicate their approval by writing |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-8.1 #54612 +/- ##
================================================
Coverage ? 71.1603%
================================================
Files ? 1465
Lines ? 422446
Branches ? 0
================================================
Hits ? 300614
Misses ? 101323
Partials ? 20509
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/retest |
2 similar comments
/retest |
/retest |
This is an automated cherry-pick of #54546
What problem does this PR solve?
Issue Number: close #54545, close #54428
Problem Summary:
This PR solve two problems:
registerConn
, and decreases inconn.Close()
(if theconn.getCtx()
is not nil). If the connection exists before handshake successfully, for example authentication failed, the total connection count will decrease one 🤦.SET SESSION_STATES
(usually used bytiproxy
) didn't INC/DEC the connection count for the resource group if it's changed.What changed and how does it work?
This PR reorganized the codes INC/DEC the metric gauge in the following pattern:
newConn
with default resource group name, so that it can make sure the connection count will always increase.closeConn
. If the connection doesn't have a valid context, it'll decrease in the default resource group.Other use case of the
ConnGauge
always comes in pair: increase one and decrease another one. This PR provides a methodSetResourceGroupName
to change the session vars and always INC/DEC the metric counter. It'll be called inSET SESSION_STATES
,SET RESOURCE GROUP
and authentication (because the user may carry a resource group info).Check List
Tests
Release note