Skip to content

Retry read queries automatically when disconnected from the database

License

Notifications You must be signed in to change notification settings

planningcenter/activerecord-retry-reads

Repository files navigation

activerecord-retry-reads

Automatically retry read queries.

Supports Rails 7.1+ and the mysql2, postgresql, sqlite3, or trilogy adapters.

Installation

In your Gemfile:

gem 'activerecord-retry-reads'

Usage

There is currently no configuration for this gem.

Why this gem?

Historically, gems like activerecord-mysql-reconnect have been used to automatically reconnect and retry queries after a disconnect from MySQL. They are not compatible with Rails >= 7.1.

Rails 7.1 added native reconnect and retry functionality, but it is extremely conservative about what queries are automatically retried. In almost every Rails app any read query is idempotent and safe to retry. If this is not true in your app, do not use this gem!

This gem expands the automatic retry functionality added in Rails 7.1 to enable retries for every read query.

Testing

Run tests with:

bundle exec appraisal install
bundle exec appraisal rake test

About

Retry read queries automatically when disconnected from the database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages