Failure on creation of a schema history table on an empty database when autoCommit is false #1983
Which version and edition of Flyway are you using?
Bug is reproduced in 5.0.* versions.
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Which database are you using (type & version)?
Which operating system are you using?
Windows 7 and Ubuntu 14
What did you do?
I simultaneously start several instances of a service on the same empty database. The service consists of his own DB schema which it migrates on startup, and it inherits another one: the core DB schema that migrates DB after completion of the service's DB migrations (similar to this approach https://stackoverflow.com/a/48272834/4070983). It uses baseline to run core migrations on non-empty DB:
The service uses table schema_version table as history table and its core part uses schema_version_common as a name for history table.
What did you expect to see?
I expect that all migrations will be completed successfully.
What did you see instead?
I see the following stacktrace:
If I start service instances one by one I don't get the error. Error is reproduced only with simultaneous start.
Apparently, this issue is somehow related to issue #1067
The text was updated successfully, but these errors were encountered:
I've found that the root cause is that I use data sources with autoCommit mode set to false. In this case even extremely simple case (just schema history table creation without any migration) fails in concurrent environment. I've reproduced it in naive test here in a separate branch.
Also, I've commited a fix in another branch. Could you take a look on it? If you find it correct, I'll create a PR.
Unfortunately, I can't find any test in the repository. So, I've checked the fix only with PostgreSQL. But I think the problem is related to other DBMSes.
…n empty database A transaction should be rolled back after an error if autoCommit mode is set to false. Every error spoils the transaction.
I had a deeper look into this and there were a number of other issues when