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

can we fix error return when connection closed [close by server or server(or proxy) restart] #998

Closed
hengkiang opened this issue Sep 9, 2019 · 4 comments

Comments

@hengkiang
Copy link

hengkiang commented Sep 9, 2019

sometimes when developer forget to call SetConnMaxLifetime(sql api), or when developer use mysql with a proxy server, and the proxy server restart.

image

at these times, the connection is closed, the api return ErrInvalidConn. but this can not distinguish the error is connection is already closed , or other unexpect error。
so, when receive this error(ErrInvalidConn), developer can not decide appropriate retry is appropriate。

so, how about to return io.EOF when receive io.EOF . such as :
image

and return driver.ErrBadConn when read the packet length, such as:
image

if return driver.ErrBadConn, the go sql api will retry again to fix closed connection, this can work gracefull
image

@shogo82148
Copy link
Contributor

Did you try #934 ?
It may resolve your issue.

@hengkiang
Copy link
Author

thank you, let me have a try

@hengkiang
Copy link
Author

@shogo82148
I have try with master, and update go with version 1.12.8, but it donnot work.
I add log to print the reset value.
image

when I suddenly restart the proxy, the reset value is not true, and it still print "unexpected EOF"
image

@methane
Copy link
Member

methane commented Sep 10, 2019

if return driver.ErrBadConn, the go sql api will retry again to fix closed connection, this can work gracefull

It is not an option. After we send any query, the query may be executed even if we received EOF.
You shouldn't restart proxy server while application is online.

@methane methane closed this as completed Sep 10, 2019
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

No branches or pull requests

3 participants