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

Checking that connection was not closed by the server before reusing it from the pool. #1002

Closed

Commits on May 7, 2021

  1. Checking that connection was not closed by the server before reusing …

    …it from the pool.
    
    Checking that conn.write() doesn't return an error during query execution is not enough to prevent errors like EOF for closed connections by the server because write() syscall returns success for the socket that received FIN packet (half-closed TCP connection).
    EOF error will  be returned only after the read() call but in this case, we cannot distinguish half-closed connection(after the previous query) and read timeout for the new query so query retry is not safe and driver propagates the error to the application.
    We use a lightweight non-blocking read from the socket that immediately returns the result in driver.ResetSession() method before a connection is reused for another query so a new connection will be taken from the pool if server initiated connection closing and application can work smoothly.
    damour committed May 7, 2021
    Copy the full SHA
    0a1a096 View commit details
    Browse the repository at this point in the history