On Sun, Dec 20, 2015 at 11:22 PM, Jeremy Evans <[email protected]> wrote:
> On Sunday, December 20, 2015 at 4:53:41 PM UTC-8, Mike Pastore wrote: >> >> On Sun, Dec 20, 2015 at 1:28 PM, Jeremy Evans wrote: >> >>> On Saturday, December 19, 2015 at 11:27:25 AM UTC-8, Mike Pastore wrote: >>>> >>>> On a somewhat-related topic, I've noticed that after I bounce the MySQL >>>> (MariaDB) server, requests start failing with: >>>> >>>> 2015-12-19 06:18:32 - Sequel::DatabaseDisconnectError - Mysql2::Error: >>>> MySQL server has gone away: >>>> >>>> >>>> Even though MySQL is back online and ready to receive queries. I have >>>> to restart Puma to get the workers to reinitialize their connections. Is >>>> there a way to make the Sequel connection pool a little more robust so it >>>> handles this situation better? >>>> >>> >>> You can use the connection_validator extension if you want to check >>> connections before use. >>> >> >> That looks interesting. I will enable that in my application. Thank you. >> >> Is there any mechanism that would allow Sequel to catch a >> Sequel::DatabaseDisconnectError (or a Mysql2::Error) and follow a logic >> flow similar to connection_validator's to remove that connection from the >> pool? >> > > Sequel automatically recognizes Sequel::DatabaseDisconnectError and > removes the connection from the pool. However, the error is reraised after > the connection is removed, since it isn't safe to just retry. You either > need to use the connection_validator extension where the connection is > validated before use, or you need to retry manually. You can retry > manually using the :retry_on=>Sequel::DatabaseDisconnectError option to > Database#transaction, if you are sure that the entire transaction block is > idempotent on transaction failure. > Thanks Jeremy. One last question. :-) I'm scaling the :max_connections of my Sequel pool to match the number of threads in the Puma process. Is there a way to do the same for the read-only connections? It looks like it's only a maintaining a single connection to each slave. Or am I going about this the wrong way? -- 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 post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
