rails / mission_control-jobs

Dashboard and Active Job extensions to operate and troubleshoot background jobs
MIT License
611 stars 71 forks source link

Mission Control seems to require an active record connection when the application typically does not #162

Closed Senjai closed 1 month ago

Senjai commented 2 months ago

On version 0.3.1, we had to recently set mission control rails to require: false, and manually require the gem in non CI environments.

Something about the way this gem loads, will attempt to invoke ActiveRecord::Base.connection on load. My hypothesis is it's something to do with https://github.com/rails/mission_control-jobs/blob/main/lib/mission_control/jobs.rb#L6

We tested this by commenting out all mount's and application configuration (e.g. no references in config/application.rb, routes, and more) before setting the gem to require: false in the Gemfile.

This is a problem because our build environment does not have a database connection set up. E.g. when running bundle exec rails assets:precompile but does in our other environments (production, development etc). I haven't yet had time to track this down further.

Ideally, Mission Control does not invoke side effects in Active Record on load, instead only doing so when the route is visited or otherwise.

Very excited about this project by the way. If necessary, I could look to setting up a proof of concept to demo the problem.

Senjai commented 1 month ago

Unfortunately, I did miss an in application issue on our end that caused this. Mission control does load models that were previously not loaded in our CI environment, but the root cause was that we had a unobvious call to column_names in one of our models that happened to be invoked via a concern at load-time. I mistakenly thought this was mission control, but it only exposed the problem, not caused it.

Apologies for the distraction here.