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

backend: fix connection won't close if graceful shutdown starts during handshake #164

Merged
merged 6 commits into from
Dec 29, 2022

Conversation

djshow832
Copy link
Collaborator

@djshow832 djshow832 commented Dec 27, 2022

What problem does this PR solve?

Issue Number: ref #161

Problem Summary:

  • In server, backend: graceful shutdown #159, if graceful shutdown starts during or before handshaking, the statusConnected or statusHandshaked overrides statusNotifyClose, which makes statusNotifyClose not work.
  • When TiProxy receives a SIGINT signal, the cmd.Context() is done, and it will stop some components, such as the goroutine which processes signalGracefulClose. Thus, the BackendConnMgr won't shutdown immediately.

What is changed and how it works:

  • Rename connStatus to closeStatus and it only manages the status of closing.
  • Create another context in SQLServer. I've checked the code of the gateway, it won't affect the gateway.

Check List

Tests

  • Unit test

  • Integration test

  • Manual test (add detailed scripts or steps below)

  • No code

  • graceful-shutdown=10 and stop the TiProxy

  • graceful-shutdown=10, send a begin statement and stop the TiProxy

  • graceful-shutdown=10, send a begin statement, stop the TiProxy, and send a commit statement

  • graceful-shutdown=0, send a begin statement and stop the TiProxy

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change (Don't forget to add the declarative for API)
  • Has tiproxyctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@djshow832 djshow832 marked this pull request as ready for review December 29, 2022 04:12
Copy link
Collaborator

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

Rest LGTM

conf/proxy.yaml Outdated Show resolved Hide resolved
pkg/proxy/client/client_conn.go Outdated Show resolved Hide resolved
@djshow832 djshow832 merged commit 68d4015 into pingcap:main Dec 29, 2022
@djshow832 djshow832 deleted the shutdown_connect branch December 29, 2022 08:57
@xhebox xhebox mentioned this pull request Dec 29, 2022
xhebox pushed a commit to xhebox/TiProxy that referenced this pull request Mar 7, 2023
xhebox pushed a commit to xhebox/TiProxy that referenced this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants