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

attempt retries to spawn connection upon transient error #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shackbarth
Copy link

Hello Sails maintainers! A problem I've recently started having on our Azure deploys is that the connection from Azure App Service to Azure Postgres can be somewhat flaky, even if they're both in the same datacenter. The attitude of Azure Support seems to be something a long the lines of: that's #cloudlife baby! In short, their expectation is that our tools are resilient enough to retry upon transient error until the connection works.

I've used the following trick in my non-waterline code and it helps avoid these errors, which are particularly vexing when they happen in the middle of an hours-long process, crashing the whole thing midstream. This seems to be the place to add it to (pg) waterline to achieve the same effect.

You can see that I've made the diffs as non-invasive as possible; that's why I'm abusing that first parameter in the recursive call instead of adding retryCount as a third parameter to the spawnConnection signature. Also, this routine is only activated if the app has put an attemptRetries value in the datastore config file (I use 4... otherwise the exponential wait gets pretty high). I'm happy to tweak parts of the implementation if you prefer. Let me know what you think!

@shackbarth
Copy link
Author

FWIW I've also recently run into connection errors against Azure not just when spawning a connection -- which this PR reflects -- but also in the execution of the query.

My fixes for those problems have been:

  1. Add an event listener for errors in the success function of spawn-connection.js
  2. Add a similar (to this PR) retry mechanism in the queryFailed function of run-query.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant