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

Fix: Running AutoMigrate concurrently on the same model fails with various race conditions #6680

Closed
wants to merge 7 commits into from

Conversation

lasse-it
Copy link

@lasse-it lasse-it commented Nov 9, 2023

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

This PR makes the migrator obtain a driver-specific lock before migrating a table.

User Case Description

This makes it possible to prevent auto-migrating from failing due to concurrent migrations in distributed systems and parallel tests.

Fixes #6618.

@lasse-it lasse-it changed the title Fix/concurrent migrations Fix: Running AutoMigrate concurrently on the same model fails with various race conditions Nov 9, 2023
@lasse-it lasse-it marked this pull request as ready for review November 9, 2023 15:50
@jinzhu
Copy link
Member

jinzhu commented Dec 4, 2023

Thank you for your PR.

Race issues in migrations are inevitable, particularly when running them on multiple servers. It's often impossible to remove all such issues.

Auto-migration is best suited for development environments and should be executed at application initialization.

@jinzhu jinzhu closed this Dec 4, 2023
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

Successfully merging this pull request may close these issues.

Running AutoMigrate concurrently on the same model fails with various race conditions
2 participants