-
Notifications
You must be signed in to change notification settings - Fork 114
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
Guidance on handling closed connections #315
Comments
If I understand correctly, the issue is that DBConnection is not very kind to changing the connection once a query starts, right? So we would need to add a mechanism that allows the adapter to say: "try again with another connection, I am going away"? |
I think we can already "swizzle" the connection without "telling" DBConnection like in plausible/ch#211. So that part seems to be OK.
Do you mean a new TCP connection entirely, or another DBConnection connection from the pool? The approach I linked above is about a new TCP connection entirely, and that seems to work but kind of feels like the TCP reconnection can happen earlier, not on ping or query attempt. If you mean another DBConnection connection from the existing pool, they might be disconnected as well. I was thinking more in terms of:
What seems to be happening right now in Ch is the following:
So that it's all correct, but could've been handled earlier without making the caller retry the query. For some additional context, I think it might be similar to sneako/finch#62, sneako/finch#272 |
Makes sense! I think this can all be implemented in the connection then, no? Without a need to change DBConnection? You should be able to receive the |
I'll try but I think |
I tried it out in plausible/ch#212 and the unmatched info messages seem to be ignored:
|
Good catch, so let's proxy those if the connection has defined a |
Sure! |
👋
I wonder if it's possible to gracefully reconnect once the underlying adapter's connection is detected to be closed to avoid
:closed
errors on user queries (DBConnection.query / DBConnection.execute)? For example, maybe we could use:inet.monitor/1
from the adapters? Maybe it could be possible to let the adapters handle_info the DOWN messages?Related Ch issues / PRs: plausible/ch#210, plausible/ch#211
The text was updated successfully, but these errors were encountered: