Question regarding multiple instances run alembic head upgrade at the same time, Does it cause risk condition? #1438
Unanswered
zch-cc
asked this question in
Usage Questions
Replies: 1 comment 2 replies
-
yah that's totally not correct, you'd have multiple connections all trying to run the same CREATE / ALTER statements etc. and conflicting. you need to run just one connection at a time with DDL in it, you can't mix those things up. usually the part of the program that runs migrations is separate from the part of the program that handles requests, so the "run the migrations" part would not be in an "auto scaled" system. it would be part of whatever your framework uses for building up initial setup. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi I have a quick question. I have a service which run alembic head upgrade every time it starts. Typically it works fine since if the db is already in the newest state, the migration does nothing. Since I put the program in auto sclaing group, so there could be multiple instances running alembic head upgrade at the same time, I want to ask if this cause risk condition? If it does, what is the best way to avoid it? One thought is to have another table with one entry to act like lock, only if you get the lock you perform the upgrade. Is there other ways to handle it? Thanks
Beta Was this translation helpful? Give feedback.
All reactions