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

Use leases instead of indefinite locks in migrator control document #83

Open
stieg opened this issue Dec 10, 2019 · 0 comments
Open

Use leases instead of indefinite locks in migrator control document #83

stieg opened this issue Dec 10, 2019 · 0 comments

Comments

@stieg
Copy link
Collaborator

stieg commented Dec 10, 2019

Right now we use a lock field to determine if we have exclusive access to migration. In normal operations this is fine because the lock will be taken, migrations happen, then released. However what does not get covered are situations where an error occurs. In example if the migrator fails to migrate down a version (say because it doesn't exist since it is a roll back in code) then the lock will be taken, the migrator will crash, and then the lock will never be released. Another scenario can also occur where the DB connection is broken and not re-established and thus the lock can not be released without first reconnecting (if possible).

Point is that a lock as a boolean type is a bad idea. A better solution would be to use a "lease" mechanism. It is similar to a lock except that instead of being a boolean it is instead a date in the future at which point the lease expires. This way if a migration fails then all future migrations will not be hamstrung until the document is fixed manually. We should be loud if we have to remove an expired lease but this is clearly an improvement over the current implementation.

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

1 participant