Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flyway sometimes fails on a clustered JDBC source #2638

Closed
Kindrat opened this issue Jan 22, 2020 · 3 comments
Closed

Flyway sometimes fails on a clustered JDBC source #2638

Kindrat opened this issue Jan 22, 2020 · 3 comments

Comments

@Kindrat
Copy link

@Kindrat Kindrat commented Jan 22, 2020

Which version and edition of Flyway are you using?

Spring Boot integration (Boot 2.1.3, Flyway 5.2.4)

If this is not the latest version, can you reproduce the issue with the latest one as well?

(Many bugs are fixed in newer releases and upgrading will often resolve the issue)
Yes

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Java API

Which database are you using (type & version)?

PostgreSQL 11

Which operating system are you using?

Kubernetes -> Docker -> debian:stretch

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)
PostgreSQL is configured in cluster mode with load balancing using PgPool II. The issue is that when Flyway runs the migration in DbMigrate#migrateAll in while loop it executes during first iteration and metadata is successfully written to master node. But immediately after that next iteration is updating local Flyway cache in JdbcTableSchemaHistory#refreshCache that is sent to Read slave that sometimes had not yet replicated from master. Migration is not read to cache and executes second time with either failing on existing table or corrupting data.

What did you expect to see?

Cache update should be either transactional to guarantee it would be send to master, or there should be some retry mechanism.

What did you see instead?

Duplicated execution of same migration.

@Lyeeedar
Copy link
Contributor

@Lyeeedar Lyeeedar commented Jan 29, 2020

We have an idea for how to fix this. Would you be interested in trying a build containing the fix to report if your issue is solved?

@Kindrat
Copy link
Author

@Kindrat Kindrat commented Jan 29, 2020

Don't know if it would be compatible with our boot version and other third-parties... Basically, I believe, making read transactional may be enough, but as for me the idea with while-true loop is not obvious. Don't see when it could be helpful to execute same flow till it returns 0 executed actions...

I may extract my PostgreSQL cluster config and try it on Minikube with very basic demo app for latest release to check. But can't say when I'll have enough free time to do that, may take a few days.

@Lyeeedar
Copy link
Contributor

@Lyeeedar Lyeeedar commented Jan 29, 2020

This may be fixed in flyway 6.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants