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

When running multiple instances of the app, baselineOnMigrate is not working properly #2243

Closed
cristinapetri opened this issue Dec 14, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@cristinapetri
Copy link

commented Dec 14, 2018

Which version and edition of Flyway are you using?

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)

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

Java API

Which database are you using (type & version)?

Mysql 5.7.12-0.3

Which operating system are you using?

CentOS

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.)

I'm integrating flyway into an existing spring boot (1.5.13.RELEASE) application. Because I have a NON-EMPTY schema, I would like to skip the already ran scripts, so the only configuration that I've set to flyway is "baselineOnMigrate: true".
I've added to V1__initial.sql the current schema of the DB, so I would like to baseline it to version 1. I'm starting 6 instances of the application.

What did you expect to see?

Multiple instances of the app are starting and initial (baselined) version of the script is ignored.

What did you see instead?

Multiple instances of the app are starting and it happens that the initial (baselined) version of the script is executed. Please see below:

installed_rank, version, description, type, script, checksum, installed_by, installed_on, execution_time, success
'1', '1', '<< Flyway Baseline >>', 'BASELINE', '<< Flyway Baseline >>', NULL, 'v4Api', '2018-12-14 10:47:52', '0', '1'
'2', '1', 'initial', 'SQL', 'V1__initial.sql', '1041230070', 'test', '2018-12-14 10:47:52', '167', '1'

Here are some logs:

One of the instances:
12:47:52.203 [main] INFO o.f.core.internal.command.DbValidate - Successfully validated 1 migrations (execution time 00:00.154s)
12:47:52.334 [main] INFO o.f.c.i.s.JdbcTableSchemaHistory - Creating Schema History table: Xflyway_schema_history
12:47:52.814 [main] INFO o.f.core.internal.command.DbBaseline - Successfully baselined schema with version: 1

Other instance:
12:47:52.504 [main] INFO o.f.core.internal.command.DbValidate - Successfully validated 1 migrations (execution time 00:00.211s)
12:47:52.650 [main] INFO o.f.core.internal.command.DbMigrate - Current version of schema X: << Empty Schema >>
12:47:52.668 [main] INFO o.f.core.internal.command.DbMigrate - Migrating schema X to version 1 - initial

@axelfontaine axelfontaine added this to the Flyway 6.0.0 milestone Jan 4, 2019

@axelfontaine axelfontaine changed the title When running multiple instances of the app, rebaseOnMigrate is not working properly When running multiple instances of the app, baselineOnMigrate is not working properly Jan 4, 2019

axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Mar 14, 2019

@axelfontaine

This comment has been minimized.

Copy link
Contributor

commented Mar 14, 2019

Thanks for reporting. This turned out to be quite tricky to fix due to MySQL implicit commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.