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

Enforce rollback for each connection when shutdown occurs #5659

Merged
merged 11 commits into from
Jan 15, 2020

Conversation

saifalharthi
Copy link
Contributor

@saifalharthi saifalharthi commented Jan 6, 2020

This fixes #5553

Signed-off-by: Saif Alharthi <[email protected]>
Signed-off-by: Saif Alharthi <[email protected]>
Signed-off-by: Saif Alharthi <[email protected]>
@saifalharthi saifalharthi marked this pull request as ready for review January 6, 2020 14:28
@saifalharthi saifalharthi changed the title [WIP] Enforce rollback for each connection when shutdown occurs Enforce rollback for each connection when shutdown occurs Jan 13, 2020
Signed-off-by: Saif Alharthi <[email protected]>
@@ -436,9 +452,17 @@ func shutdownMysqlProtocolAndDrain() {
}
}

func rollbackAtShutdown() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to hold mutex here, because you're accessing connections. However, you'll run into a deadlock because ConnectionClosed also obtains the mutex.

I recommend implementing a CloseAllConnections instead of ConnectionClosed, that obtains the mutex and closes all conections in a loop.

And then, you can change servenv.OnClose(rollbackAtShutdown) -> servenv.OnClose(vtgateHandler.CloseAllConnections)

The previous approach we tried led to some race conditions.
This new approach of just hard-closing the connection and
then wait for the cleanup to happen from that effect feels
more stable.

Signed-off-by: Sugu Sougoumarane <[email protected]>
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.

VTGate does not rollback in-flight transactions when shut down
2 participants