Я конвертирую проект из MySQL в PostgreSQL.После его настройки, когда я запускаю rake db:create
или rake db:migrate
, я получаю сообщение об ошибке: ActiveRecord::ConnectionTimeoutError: could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use
.
Я попытался увеличить пул до 50. Другой проект rails на той же машине прекрасно использует PostgreSQL.Есть идеи, что может происходить?
Полная трассировка стека:
ActiveRecord::ConnectionTimeoutError: could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:202:in `block in wait_poll'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:193:in `loop'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:193:in `wait_poll'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:154:in `internal_poll'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:278:in `internal_poll'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:148:in `block in poll'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:158:in `synchronize'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:148:in `poll'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:747:in `acquire_connection'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/connection_handling.rb:88:in `connection'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/schema_migration.rb:20:in `table_exists?'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/schema_migration.rb:24:in `create_table'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/migration.rb:1125:in `initialize'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/migration.rb:1007:in `new'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/migration.rb:1007:in `up'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/migration.rb:985:in `migrate'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/activerecord-5.1.6.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/bin/ruby_executable_hooks:24:in `eval'
/Users/tonyporteous/.rvm/gems/ruby-2.5.3@citydash/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Секция файла конфигурации выглядит следующим образом:
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: projectx_development
Я добавил гем какэто:
gem 'pg', '>= 0.18', '< 2.0'