MetaDataTable not updated with autoCommit false #1534
Closed
Milestone
Comments
Note for future issues: please use the template we provided as it avoids the need to ask the following questions. Which database + version are you using? Can you share a small test case that reproduces the issue? |
I skipped the template because it seemed mostly irrelevant. I've filled it now out below. I have now also created some test code showing the issue: https://github.com/fabian/flyway-autocommit-issue What version of Flyway are you using?4.1.1 Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)Java API What database are you using (type & version)?MySQL 5.7.17 What operating system are you using?macOS 10.12.3 What did you do?(Please include the content causing the issue, any relevant configuration settings, and the command you ran) HikariDataSource dataSource = new HikariDataSource();
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/flyway");
dataSource.setUsername("root");
dataSource.setAutoCommit(false);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.migrate(); What did you expect to see?Migration in What did you see instead?Empty |
pradheeps
pushed a commit
to pradheeps/flyway
that referenced
this issue
Mar 7, 2017
dohrayme
pushed a commit
to dohrayme/flyway
that referenced
this issue
Feb 3, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to affect Flyway 4.1 and later. So far we've been using Flyway 3 where this wasn't an issue.
If the DataSource used for Flyway has
autoCommit=false
, the meta data tableschema_version
is not updated after a migration has been executed.I've searched around in the source code and I suspect the bug has probably been introduced with #851 when the
TransactionTemplate
was replaced with a metaDataTable lock:b258cb4#diff-f8b70833a92c52372a5327e6765f414dL148
Before this commit, applying the migration and updating the meta data table (
applyMigration
) were wrapped in one transaction which made sure the meta data table changes got committed.Maybe a
TransactionTemplate
should be added inMetaDataTableImpl.addAppliedMigration
?The text was updated successfully, but these errors were encountered: