Project

General

Profile

Actions

Refactor #18551

closed

table_exists? in initializer should ignore missing database

Added by Dominic Cleal almost 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Under Rails 5, initializing the Foreman app with a missing MySQL or PostgreSQL database fails in the config/initializers/foreman.rb file which calls table_exists?:

Mysql2::Error: Unknown database 'test_develop_pr_core-0-dev'
gems/mysql2-0.4.4/lib/mysql2/client.rb:87:in `connect'
gems/mysql2-0.4.4/lib/mysql2/client.rb:87:in `initialize'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_connection'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:721:in `new_connection'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:765:in `checkout_new_connection'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:744:in `try_to_checkout_new_connection'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in `acquire_connection'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:501:in `checkout'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:875:in `retrieve_connection'
gems/activerecord-5.0.0/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
gems/activerecord-5.0.0/lib/active_record/connection_handling.rb:91:in `connection'
gems/activerecord-5.0.0/lib/active_record/model_schema.rb:248:in `table_exists?'
config/initializers/foreman.rb:36:in `<top (required)>'

The initializer should ignore any connection failures here, as with nearby table_exists? calls as the database may not exist (initialising the app is a pre-requisite to DB setup tasks).

Rails 5 differs from 4.2 as it no longer uses a schema cache to answer the table_exists? method call.

Actions #1

Updated by The Foreman Bot almost 8 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4298 added
Actions #2

Updated by Dominic Cleal almost 8 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #3

Updated by Dominic Cleal almost 8 years ago

  • Translation missing: en.field_release set to 209
Actions

Also available in: Atom PDF