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

Conversation

team-gateway-bot
Copy link
Collaborator

Backport d2da4db from #11480.

#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 windmgc force-pushed the backport-11480-to-release/3.3.x branch from c53dac5 to d2076e3 Compare September 18, 2023 03:59
@windmgc windmgc merged commit 9b6674f into release/3.3.x Sep 18, 2023
23 checks passed
@windmgc windmgc deleted the backport-11480-to-release/3.3.x branch September 18, 2023 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants