attempt retries to spawn connection upon transient error #294
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!