Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parallel_migration_threads of anything greater than 1 raises ActiveRecord::ConcurrentMigrationError #298

Open
jwg2s opened this issue Oct 30, 2024 · 2 comments

Comments

@jwg2s
Copy link

jwg2s commented Oct 30, 2024

Steps to reproduce

  • Set config.parallel_migration_threads = 4 (really anything greater than 1 will expose the issue)
  • Run bundle exec rake db:migrate

Expected behavior

  • All schemas should be migrated without error

Actual behavior

  • ActiveRecord::ConcurrentMigrationError error is raised, migrations fail.
ActiveRecord::ConcurrentMigrationError:

Cannot run migrations because another migration process is currently running.

System configuration

  • Database: Postgres v14.12

  • Apartment version: Happens regardless of ros-apartment version, but confirmed on 3.1.0 and 2.11.0

  • Apartment config (in config/initializers/apartment.rb or so):

    • use_schemas: true
    • parallel_migration_threads: 4
  • Rails (or ActiveRecord) version: 6.1.7.9

  • Ruby version: 3.1.4

@mnovelo
Copy link
Collaborator

mnovelo commented Oct 30, 2024

@jwg2s I need to update our README that parallel migrations won't work unless you implement your own schema-aware advisory locks for migrations. I'm seeking advise for how to advise users who want to use parallel migrations rails/rails#43500 (comment)

@mnovelo
Copy link
Collaborator

mnovelo commented Oct 30, 2024

@jwg2s try disabling advisory_locks as noted here https://blog.saeloun.com/2019/09/09/rails-6-disable-advisory-locks/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants