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

enhance graceful stop by closing the connection after finishing the ongoing txn #32110

Closed
july2993 opened this issue Feb 6, 2022 · 0 comments · Fixed by #32111 or #42134
Closed

enhance graceful stop by closing the connection after finishing the ongoing txn #32110

july2993 opened this issue Feb 6, 2022 · 0 comments · Fixed by #32111 or #42134
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. sig/sql-infra SIG: SQL Infra type/enhancement The issue or PR belongs to an enhancement.

Comments

@july2993
Copy link
Contributor

july2993 commented Feb 6, 2022

Enhancement

ref

func (s *Server) GracefulDown(ctx context.Context, done chan struct{}) {

Instead of checking all connections in tick(1s) and notifying it to close if the status is not in txn, we can make the connection in func (cc *clientConn) Run(ctx context.Context) to detect if we are going to shutdown and close the connection after executing the ongoing txn.

The current implementation may be hard to close the connection if the connection is actively executing txns.
And there race cases between ShutdownOrNotify and clientConn.Run, like:

  1. status is connStatusDispatching after reading a "start transaction" statement but sessionVar.InTxn() is still false.
  2. status is set as connStatusWaitShutdown in ShutdownOrNotify()
  3. we will close the connection directly after dispatching the "start transaction" statement.
@july2993 july2993 added the type/enhancement The issue or PR belongs to an enhancement. label Feb 6, 2022
@july2993 july2993 changed the title enhance graceful stop by closing connection after finish the ongoing txn enhance graceful stop by closing the connection after finishing the ongoing txn Feb 6, 2022
@djshow832 djshow832 added the affects-6.5 This bug affects the 6.5.x(LTS) versions. label Nov 27, 2023
@jebter jebter added the sig/sql-infra SIG: SQL Infra label Nov 27, 2023
ti-chi-bot bot pushed a commit that referenced this issue Nov 28, 2023
crazycs520 pushed a commit to crazycs520/tidb that referenced this issue Nov 29, 2023
crazycs520 added a commit that referenced this issue Nov 29, 2023
crazycs520 added a commit that referenced this issue Nov 29, 2023
guoshouyan pushed a commit to guoshouyan/tidb that referenced this issue Mar 5, 2024
guoshouyan pushed a commit to guoshouyan/tidb that referenced this issue Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. sig/sql-infra SIG: SQL Infra type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
3 participants