transaction_connection_validator.rb

lib/sequel/extensions/transaction_connection_validator.rb
Last Update: 2024-01-03 16:27:02 -0800

The transaction_connection_validator extension automatically retries a transaction on a connection if an disconnect error is raised when sending the statement to begin a new transaction, as long as the user has not already checked out a connection. This is safe to do because no other queries have been issued on the connection, and no user-level code is run before retrying.

This approach to connection validation can be significantly lower overhead than the connection_validator extension, though it does not handle all cases handled by the connection_validator extension. However, it performs the validation checks on every new transaction, so it will automatically handle disconnected connections in some cases where the connection_validator extension will not by default (as the connection_validator extension only checks connections if they have not been used in the last hour by default).

Related module: Sequel::TransactionConnectionValidator