Skip to content

EE load balancing code doesn't work with Rails 5

Upon deploying the first 10.6 RC to staging, Unicorn blew up with https://sentry.gitlab.net/gitlab/staginggitlabcom/issues/578213:

ArgumentError: wrong number of arguments (given 4, expected 1..3)
  from gitlab/database/load_balancing/connection_proxy.rb:33:in `select_all'
  from active_record/querying.rb:39:in `find_by_sql'
  from active_record/relation.rb:706:in `exec_queries'
  from active_record/relation.rb:583:in `load'
  from active_record/relation.rb:260:in `records'
  from active_record/relation.rb:256:in `to_a'
  from active_record/relation/finder_methods.rb:563:in `find_nth_with_limit'
  from active_record/relation/finder_methods.rb:592:in `find_nth_with_limit_and_offset'
  from active_record/relation/finder_methods.rb:545:in `find_nth'
  from active_record/relation/finder_methods.rb:122:in `first'
  from active_record/relation/finder_methods.rb:154:in `last'
  from active_record/querying.rb:3:in `last'
  from license.rb:226:in `load_license'
  from license.rb:211:in `block in current'
  from request_store.rb:47:in `fetch'
  from license.rb:211:in `current'
  from license.rb:217:in `feature_available?'
  from gitlab/auth/smartcard.rb:9:in `enabled?'
  from ee/auth_helper.rb:45:in `smartcard_enabled?'
  from ee/auth_helper.rb:35:in `form_based_providers'

The problem is select_all added a preparable argument (https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-select_all) that isn't handled in the code.