Order-dependent spec failure: spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb
Job #1538546942 failed for 2d10648b:
This can be reproduced via:
bundle exec rspec spec/lib/gitlab/database/load_balancing_spec.rb spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb
1) Gitlab::Database::LoadBalancing::ConnectionProxy.insert_all! inserts data in bulk
Failure/Error: connection.send(...)
ActiveRecord::StatementInvalid:
PG::UndefinedTable: ERROR: relation "connection_proxy_bulk_insert" does not exist
LINE 1: SELECT COUNT(*) FROM "connection_proxy_bulk_insert" /*applic...
^
# ./lib/gitlab/database/load_balancing/connection_proxy.rb:95:in `block in read_using_load_balancer'
# ./lib/gitlab/database/load_balancing/load_balancer.rb:39:in `read'
# ./lib/gitlab/database/load_balancing/connection_proxy.rb:94:in `read_using_load_balancer'
# ./lib/gitlab/database/load_balancing/connection_proxy.rb:47:in `select_all'
# ./spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb:104:in `block (4 levels) in <top (required)>'
# ./spec/lib/gitlab/database/load_balancing/connection_proxy_spec.rb:99:in `block (3 levels) in <top (required)>'
# ./spec/spec_helper.rb:392:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:383:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:379:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:31:in `with_raw_context'
# ./spec/spec_helper.rb:379:in `block (2 levels) in <top (required)>'
# ./spec/support/database/prevent_cross_joins.rb:81:in `block (3 levels) in <top (required)>'
# ./spec/support/database/prevent_cross_joins.rb:52:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:81:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# PG::UndefinedTable:
# ERROR: relation "connection_proxy_bulk_insert" does not exist
# LINE 1: SELECT COUNT(*) FROM "connection_proxy_bulk_insert" /*applic...
# ^
# ./lib/gitlab/database/load_balancing/connection_proxy.rb:95:in `block in read_using_load_balancer'
It appears RequestStore
is leaking a Host
across specs, causing the load balancer to be used in connection_proxy_spec.rb
. Using SafeRequestStore
and proper use of the :request_store
annotation, but this introduces other spec failures in load_balancing_spec.rb
.
Edited by Stan Hu