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

Why do Session Settings get reset on a connection? #2200

Open
ldaIas opened this issue May 15, 2024 · 0 comments
Open

Why do Session Settings get reset on a connection? #2200

ldaIas opened this issue May 15, 2024 · 0 comments

Comments

@ldaIas
Copy link

ldaIas commented May 15, 2024

Hello, I had a question concerning the behavior when connections are returned to the pool. For background, we are working with Java 21, HikariCP 5.0.1, and PostgreSQL 15.5

In our application, we make prepared statements such as "SET statement_timeout=xxx" when we first retrieve a connection from the pool. We found we were executing these a lot and wanted to cut down, so we cached the previously executed timeout values on the clientInfo Property on the connection. When getting a new connection from the pool, if we see that the timeout values have already been cached on it's clientInfo, we won't run the query again. We had been assuming that a connection in the pool will not have its session and session settings reset, so that is how we arrived at the solution of not running the query again, since we thought the values would still be on the connection.

What we are finding is that either our assumption is wrong or we misconfigured something. When we get a connection back from the pool that has had its clientInfo modified and immediately query for the timeout values, we see that they are 0 instead of the previously set value. What we want to know is if these values are being reset every time we get the connection from the pool or put it back, or if we misconfigured something somewhere.

I have looked at resetConnectionState() but that only seems to reset the properties of the connection, not settings that would be in the database, but please correct me if wrong.

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

1 participant