-
Notifications
You must be signed in to change notification settings - Fork 51
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
Issue when trying to reconnect to a restarted Docker postgres DB #181
Comments
I think this is expected right, but that we would expect Askar / SQLx to automatically handle closed sessions / connections rather than us having to manually recreate all the connections to the database? |
Yeah it is expected, but the weird part is is that it works with a local database when that is restarted. There is a slight issue there because the docker container is restarted with |
Could it have something to do with this issue? Not sure, but it also has some different behaviour depending on local vs remote: launchbadge/sqlx#2698 |
Each session wraps a PoolConnection, which does not (to my knowledge) support reconnection. Sessions are expected to be held for a short time before releasing the connection back to the pool, as otherwise you would likely hit the maximum number of open connections. It's strange to me that it would work with a local DB, as it would still need to reestablish the (TLS) connection and recreate any prepared statements. I'm not sure I totally understand where you're seeing this problem, though. |
The problem we're experiencing is with neon.tech which will drop connections / restart sometimes. We are closing sessions immediately for tenants, but the root session for the main wallet is kept open indefinitely. It's on our roadmap to work better with sessions in AFJ, but currently it's not so easy to change this behaviour. So would you suggestion be to fix this in AFJ by improving the session handling logic? |
This may be resolved by the update to sqlx 0.7.3 |
It is an issue inside of
sqlx
, but I will also open it here to keep track of it.issue: launchbadge/sqlx#2763
Short version of it is that when we use a Postgres database within a Docker container, we cannot reuse the session when the container restarts. This all works when it is a local database however.
Small snippet with askar to reproduce:
cargo.toml
src/main.rs
The text was updated successfully, but these errors were encountered: