-
Notifications
You must be signed in to change notification settings - Fork 30
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
Race condition on generated filenames using timestamps #31
Comments
The incremental names approach was suggested by @vladfaust on #20 |
Another approach to solve this, is waiting at least sleep 1.millisecond
migration_file = Micrate.create(ARGV.shift, Time.now, migrations_path)
puts "Created #{migration_file}" on: Lines 46 to 47 in 4168d23
WDYT? |
Sleeping before creating the file isn't going to prevent a race condition, it's just going to move it down the road a little bit. Generating a file with a timestamp, no matter how specific that timestamp, is always going to be subject to a race condition. Adding more digits to the migration timestamp isn't the answer either. What about adding a "does this file exist?" check in the Micrate.create method? That will still be subject to a race condition when multiple migrations are generated concurrently, but running two commands consecutively will be safe. |
Interesting idea, Thank you for sharing it, I going to try that as well 😅 |
Already fixed this on micrate Please see: https://github.com/amberframework/micrate/releases/tag/v0.3.1 |
Fixed by #33 |
Is this done? Would like to close this ticket and draft a new release |
Hi @amberframework/contributors This issue is causing Travis Failures
Please, see amberframework/amber#775 (comment)
I suggest to fix it by using incremental names or wait at least
1.millisecond
before generate migration file.The text was updated successfully, but these errors were encountered: