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

Reconnect after connection loss #49

Open
eqbalz opened this issue Apr 9, 2024 · 1 comment
Open

Reconnect after connection loss #49

eqbalz opened this issue Apr 9, 2024 · 1 comment

Comments

@eqbalz
Copy link

eqbalz commented Apr 9, 2024

Is there a good way to detect temporary connection loss and attempt to reconnect maybe a predefined number of times? I am trying to use Hammerdb for Postgres sending couple of queries to a read replica which sometimes restarts under certain conditions and I want to continue the test by retrying a few times.

@resuna
Copy link
Member

resuna commented Apr 10, 2024

One thing we do for long-running connections is to catch errors and probe with a "select(1)" statement to see if the connection is really down, and retry the connection at the application level. For intermittent connections when we suspect we may not have connected in a while we do that test pre-emptively.

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

2 participants