Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use ActiveRecord::Base as parent class #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Apr 11, 2024

  1. Don't use ActiveRecord::Base as parent class

    We've been facing performance issues with our delayed jobs table.
    One of the initiatives we're experimenting on is using a separate database for delayed jobs.
    Rails supports multiple database connections since version 6.0 using `ActiveRecord::ConnectionHandling#connects_to`.
    
    However, since 6.1, Rails does not allow using `connects_to` in non abstract classes to avoid opening multiple connections to the database.
    The recommeneded way to do it is to create a new abstract class and have your models that need a different connection inherit from that new abstract class.
    
    Also, the current version of the delayed job active record backend does not support connection config.
    The quickest work around  is to make Delayed::Backend::ActiveRecord::Job inherit from a new abstract class Delayed::Backend::ActiveRecord::Base that can be monkey patched with minimal impact.
    mateuscruz committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    13fd3dd View commit details
    Browse the repository at this point in the history