Failure on creation of a schema history table on an empty database when autoCommit is false #1983
Comments
Thanks for the report. Could you share a small repo that reproduces the issue? |
Hi Axel, 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. |
I am wondering whether you could be running in #1959 here. Can you try building master and see if the problem persists? |
The issue is actual for master. Actually, I've created the test in a branch just for the reason of separating it from master branch. |
…n empty database A transaction should be rolled back after an error if autoCommit mode is set to false. Every error spoils the transaction.
Commit introduces a test that reproduces the issue.
Commit introduces a test that reproduces the issue.
@apanasevich, nice catch! Thanks for the fix! |
I had a deeper look into this and there were a number of other issues when |
…n empty database when autoCommit is false
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)
Java API.
Which database are you using (type & version)?
PostgreSQL 9.6
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: