Skip to content

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

Closed
@hengkiang

Description

@hengkiang

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions