I am just wondering how Flyway deals with the fact that several dynos can try to run a database migration several times in a clustered environment such as Heroku thereby causing a conflict?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It seems Flyway uses locking in order to deal with this issue.
To quote the documentation:
Can multiple nodes migrate in parallel? Yes! Flyway uses the locking technology of your database to coordinate multiple nodes. This ensures that even if even multiple instances of your application attempt to migrate the database at the same time, it still works. Cluster configurations are fully supported.
回答2:
This question explains a bit more how the locking behaviour works. It appears to acquire a lock on the Flyway schema table: select * from dbschema.schema_version for update
which might cause problems for longer running migrations as the innodb_lock_wait_timeout
setting might cause a timeout, at least in the case of MySQL.