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

[Backport release/3.3.x] fix(postgres): close socket actively when timeout happens during query #11587

Merged
merged 1 commit into from
Sep 18, 2023

Commits on Sep 18, 2023

  1. fix(postgres): close socket actively when timeout happens during query (

    #11480)
    
    Currently, we do set/keep socket keepalive after every Postgres SQL query, based on keepalive timeout configured or lua_socket_keepalive_timeout(default 60s).
    This could go wrong under some cases, when a query encounters read timeout when trying to receive data from a database with high load, the query ends on Kong's side but the query result may be sent back after timeout happens, and the result data will be lingering inside the socket buffer, and the socket itself get reused for subsequent query, then the subsequent query might get the incorrect result from the previous query.
    
    The PR checks the query result's err string, and if any error happens, it'll try to close the socket actively so that the subsequent query will establish new clean ones.
    
    Fix FTI-5322
    
    (cherry picked from commit d2da4db)
    windmgc committed Sep 18, 2023
    Configuration menu
    Copy the full SHA
    d2076e3 View commit details
    Browse the repository at this point in the history