You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use postgres 11, pg gem 1.1.4 (might be relevant, I'm unsure)
Run bin/rails db:create db:migrate db:test:prepare
Get error ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR: database "team_app" is being accessed by other users DETAIL: There is 1 other session using the database.
Note: I can only replicate on CI
Expected behavior
Run bin/rails db:create db:migrate db:test:prepare
Succeeds
Actual behavior
I was able to bisect the diff between Rails 6.0.2.2 and Rails 6.0.3 and determine that this PR (#38235) introduced a bug that causes migrations to fail in my app's CI.
When my CI system runs bin/rails db:create db:migrate db:test:prepare, it used to succeed with no problem in 6.0.2.2. Now it fails with:
ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR: database "team_app" is being accessed by other users
DETAIL: There is 1 other session using the database.
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `async_exec'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `block (2 levels) in execute'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:91:in `block in execute'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/home/runner/work/team_app/team_app/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
...
Oddly enough, I cannot replicate this locally, only on CI, so I'm at a loss of next steps.
The Postgres that I am using is the default postgres that comes with GitHub Actions.
Workaround
Split up the command. Instead of bin/rails db:create db:migrate db:test:prepare, run bin/rails db:create db:migrate; bin/rails db:test:prepare`. This seems to clean up connections and we are all happy.
Steps to reproduce
bin/rails db:create db:migrate db:test:prepareActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR: database "team_app" is being accessed by other users DETAIL: There is 1 other session using the database.Note: I can only replicate on CI
Expected behavior
bin/rails db:create db:migrate db:test:prepareActual behavior
I was able to bisect the diff between Rails 6.0.2.2 and Rails 6.0.3 and determine that this PR (#38235) introduced a bug that causes migrations to fail in my app's CI.
When my CI system runs
bin/rails db:create db:migrate db:test:prepare, it used to succeed with no problem in 6.0.2.2. Now it fails with:Oddly enough, I cannot replicate this locally, only on CI, so I'm at a loss of next steps.
The Postgres that I am using is the default postgres that comes with GitHub Actions.
Workaround
Split up the command. Instead of
bin/rails db:create db:migrate db:test:prepare, runbin/rails db:create db:migrate; bin/rails db:test:prepare`. This seems to clean up connections and we are all happy.System configuration
Rails version: bf11820
Ruby version: 2.6.6