Fix rake gitlab:setup failing on new installs
For source installs, running rake gitlab:setup
will fail with this
error:
$ bundle exec rake gitlab:setup RAILS_ENV=production
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "features" does not exist LINE 8: WHERE a.attrelid = '"features"'::regclass
This happens because the setup Rake task does the following:
- Checks that Gitaly servers are up
- The gRPC message attempts to send the activated feature flags in the metadata.
- However, since the
features
table doesn't exist, this fails.
To fix this, we just return an empty set if the features
table doesn't
exist. Note that in Rails 6 the table_exists?
call is cached: https://github.com/rails/rails/blob/f3ebd0ad2252fec1728ab10275e3f14c79220d25/activerecord/lib/active_record/model_schema.rb#L340
Closes #212759 (closed)
Benchmarks
No signficant performance change:
Calculating -------------------------------------
orig 2.745k i/100ms
new 2.989k i/100ms
-------------------------------------------------
orig 31.731k (±16.7%) i/s - 153.720k
new 31.976k (±15.8%) i/s - 155.428k
Comparison:
new: 31975.6 i/s
orig: 31731.2 i/s - 1.01x slower
Edited by Yorick Peterse