I have an API server running sinatra/thin/sequel connected to a managed 
Postgres database provided by Azure Database for PostgreSQL.

For background to my problem I refer to this: 
https://docs.microsoft.com/en-us/azure/postgresql/concepts-connectivity

I need to deal with this case of what Azure terms a transient error where 
"...a connection to the database server being dropped. Also new connections 
to a server can't be opened." for up to 60 seconds. Currently this means 
our application will raise Sequel::DatabaseDisconnectError for every single 
request for the duration of this outage.

Microsoft recommends I implement a retry mechanism as such:

Wait for 5 seconds before your first retry.
> For each following retry, the increase the wait exponentially, up to 60 
> seconds.
> Set a max number of retries at which point your application considers the 
> operation failed.


I am thinking I should try to implement this at the point where a 
connection is being checked out from the connection pool. At present I am 
using connection_validator extension with timeout set to 15 minutes which 
has solved the idle disconnect issue. Should I then set it at -1 instead 
and then try to patch 
Sequel::ConnectionValidator#acquire with this retry pattern?

Is this the right way to go about it?

Thanks,
Eugene.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/ee0a20cd-4196-460f-ade2-ff4a280a929a%40googlegroups.com.

Reply via email to