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

Connection count metric can be less than the real value #51889

Closed
YangKeao opened this issue Mar 19, 2024 · 3 comments · Fixed by #51996
Closed

Connection count metric can be less than the real value #51889

YangKeao opened this issue Mar 19, 2024 · 3 comments · Fixed by #51996
Assignees
Labels
affects-7.5 found/community The community has encountered this bug. severity/moderate sig/sql-infra SIG: SQL Infra type/bug This issue is a bug.

Comments

@YangKeao
Copy link
Member

This issue has similar reason with #42761, because the conn.Close() will be called multiple times 🤦.

func (s *Server) onConn(conn *clientConn) {
...
	defer func() {
		terror.Log(conn.Close())
		logutil.Logger(ctx).Debug("connection closed")
	}()
...
}

And

func (cc *clientConn) Run(ctx context.Context) {
	defer func() {
		...
		if cc.getStatus() != connStatusShutdown {
			err := cc.Close()
			terror.Log(err)
		}

		close(cc.quit)
	}()

We have two ways to solve this problem:

  1. Don't include any logic in conn.Close(). Only have logic in the sync.Once inside the closeConn.
  2. Enhance the code, don't close the connection for multiple times! (it's more intuitive for the developers).
@YangKeao YangKeao added type/bug This issue is a bug. severity/moderate labels Mar 19, 2024
@YangKeao
Copy link
Member Author

ref #32111

@aytrack aytrack added the sig/sql-infra SIG: SQL Infra label Mar 19, 2024
@YangKeao YangKeao self-assigned this Mar 20, 2024
@YangKeao
Copy link
Member Author

Also, #49424 didn't consider the situation that the resource group name may change 😠 .

@seiya-annie
Copy link

/found community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 found/community The community has encountered this bug. severity/moderate sig/sql-infra SIG: SQL Infra type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants