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

CockroachDB: The same migration is being tried to be executed twice #2949

Closed
gendolf3d opened this issue Sep 25, 2020 · 4 comments
Closed

CockroachDB: The same migration is being tried to be executed twice #2949

gendolf3d opened this issue Sep 25, 2020 · 4 comments
Labels
Milestone

Comments

@gendolf3d
Copy link

Which version and edition of Flyway are you using?

Community integration Spring Boot and Flyway 6.5.5

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

CockroachDB 20.1.5

Which operating system are you using?

docker based on openjdk:alpine

What did you do?

Several Kubernetes pods are being started in the same time and each pod is calling Flyway to apply migration. In rare cases, it's caused some weird race condition and the same migration is being tried to be executed twice.

What did you expect to see?

Each migration is being executed only once.

What did you see instead?

The same migration is being tried to be executed twice. The second time it's failed of course and application not able to start due to failed migration:

installed_rank | version |        description        | type |              script               |  checksum  |    installed_by    |           installed_on           | execution_time | success
-----------------+---------+---------------------------+------+-----------------------------------+------------+--------------------+----------------------------------+----------------+----------
               1 | 1       | CreateUsersTable          | SQL  | V1__CreateUsersTable.sql          | -237158034 | user | 2020-09-24 22:53:08.739391+00:00 |            451 |  true
               2 | 2       | CreateAgentsTable         | SQL  | V2__CreateAgentsTable.sql         | 1130122024 | user | 2020-09-24 22:53:09.511436+00:00 |            445 |  true
               3 | 3       | AddExternalIdToUsersTable | SQL  | V3__AddExternalIdToUsersTable.sql | 1336211372 | user | 2020-09-24 22:53:10.806727+00:00 |           1107 |  true
               4 | 3       | AddExternalIdToUsersTable | SQL  | V3__AddExternalIdToUsersTable.sql | 1336211372 | user | 2020-09-24 22:53:11.016751+00:00 |            211 |  false
(4 rows)

Workaround Manually remove failed migration record from flyway_schema_history table.

@MikielAgutu MikielAgutu added this to the Flyway 7.0.1 milestone Sep 30, 2020
@DoodleBobBuffPants
Copy link
Contributor

Hi. Was there any reason running flyway repair didn't remove the failed entry?

@gendolf3d
Copy link
Author

Because I'm using Flyway as Spring Boot integration but not CLI.

@gendolf3d
Copy link
Author

Why it just was closed? is it expected behaviour? Could you please provide more on this.

@Lyeeedar
Copy link
Contributor

Lyeeedar commented Oct 5, 2020

It was fixed in commit 721325d, which will be released in Flyway 7.0.1

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

No branches or pull requests

4 participants