-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[9.x] Make migrate
command isolated
#44743
Conversation
afa6d8b
to
ba24120
Compare
0c523a6
to
ae342bc
Compare
b519765
to
93832e0
Compare
93832e0
to
04a9a4b
Compare
Interesting overall, but when you look at a generic |
@deleugpn Would you feel better about it if it was a flag? So you say |
I definitely think this should be behind some kind of flag to reduce the chance of breaking changes. |
Alright, I have added a flag named |
d4739c4
to
b074952
Compare
Added ability to customize the lock expiration time. Also added ability to specify the exit code ( |
Interface renamed to |
migrate
command isolatedmigrate
command isolated
Why does this use
|
This PR makes the
migrate
command isolated which limits the migration command to only have one process active at once. Meaning two servers cannot both runmigrate
at the same time.Problem
When deploying on multiple servers at once, it needs to be decided which of these servers have the responsibility for running migrations, however this means that all the deployments to all the servers are not identical, to simplify deployments.
For example when using k8s, you would use something like
initContainers
for running things like migrations. However as this will happen on each replica it could result in two servers running the same migration at the same time, as there is no locking so only one server will run one migration.Other people talking about this issue
Solution
Make migrate command isolated. This could in theory still result in the command running twice in the same deployment, however not at the same time, so it won't cause any issues, it will however result in queries to the database to check if migrations are missing where we already know there are none missing.
This solution works by adding the
Isolated
interface to a command which marks the command as an isolated command and it will now only run on one server. This implementation would allow to easily make other commands run in isolated when needed.An alternative solution could be to instead make this a flag called
isolated
so the user can choose when running the command to run it isolated or not. This solution could be added as a parameter available for all commands by default.