When a new connection is being added to a pool, I need a way to check a variable on the server and possibly reject the connection. The idea being that the new connection would gracefully be closed and the pool would attempt to create new connections until the validation was successful or some timeout occurred.
At first glance, it seemed the *ConnectionValidator* extension was right for the job. However, if I'm reading the source right, it executes the validation statement if the connection has been sitting the pool for awhile, not when the connection is first created. I've tried using the `after_connect` callback option, however there doesn't seem to be away for the callback to signal to the pool that the current connection should be closed and retried. This might be a feature request, but I'm hoping I missed something with the current options. I don't think it makes a difference, but if anyone wants context. I use mysql2 for an AWS Aurora connection. The behavior of Aurora during a failover is to promote a read-only node to the primary read-write node. Then (depending on the type of failover) the previous primary stays around, but gets demoted to a read-only node. When the app attempts to reconnect the severed connections, depending on how DNS resolves, there is a window of time when the app could reconnect to the old primary that is now a read-only. The recommendation from AWS is to query "*SHOW GLOBAL VARIABLES LIKE 'innodb_read_only';*" and if the value is "ON" attempt a reconnect. -- 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/b209b464-a71c-4bec-9fd0-e95a7172ca35n%40googlegroups.com.
