How does Flyway deal with the fact that several dy

2019-05-31 01:34发布

问题:

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.



标签: heroku flyway