Skip to content

Speed up CI job `rspec frontend_fixture` by skipping database load balancing

Lin Jen-Shin requested to merge test-db-load-balance into master

What does this MR do and why?

Skip:

  • ActiveRecord::Base.singleton_class.prepend(Gitlab::Database::LoadBalancing::ActiveRecordProxy) and
  • Gitlab::Database.main.disable_prepared_statements

For rspec frontend_fixture related jobs, because they're critical to other frontend jobs and will need to run faster.

How faster was this?

For rspec frontend_fixture 1/2 https://gitlab.com/gitlab-org/gitlab/-/jobs/1635012421

==> 'bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee' succeeded in 26 seconds.

Whereas for the same job on master https://gitlab.com/gitlab-org/gitlab/-/jobs/1634810972

==> 'bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee' succeeded in 119 seconds.

And overall that's 6m34s vs 8m49s. A lot of frontend jobs can only run after this, so this is pretty critical, and it probably doesn't really need to care about database load balancing after all.

Background

Experimenting for #341757 (closed)

Testing with/without this line:

  • ActiveRecord::Base.singleton_class.prepend(Gitlab::Database::LoadBalancing::ActiveRecordProxy)

And see how long this command runs in CI:

  • bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee

Results:

Failed attempts to optimize this


See #341757 (closed)

Related changes: !71459 (closed)

Edited by Lin Jen-Shin

Merge request reports