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 9.19.3 migrate hangs forever on second non-transactional migration #3682

Closed
TheHenrick opened this issue Jun 7, 2023 · 24 comments
Closed

Comments

@TheHenrick
Copy link

TheHenrick commented Jun 7, 2023

Which version and edition of Flyway are you using?

9.19.3 docker image

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)

CLI in docker

Which database are you using? (Type & version)

postgres 13

Which operating system are you using?

alpine (docker)

What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)

Command:

flyway -url=jdbc:postgresql://db:5432/postgres -schemas=public -user=user -password=password -connectRetries=60 -outOfOrder="true" -postgresql.transactional.lock=false migrate

Migrations that have worked before suddenly freeze on the second non-transactional query using the latest docker image release (9.19.3).

What I've tried:

  • I tested the previous image (9.19.1) and verified it works as expected
  • I rearranged the queries and verified the migration halts on non-transactional queries
  • I tested that I get the exact same behavior on 9.19.1 when removing the -postgresql.transactional.lock=false flag
What did you expect to see?

I expected migrations to complete (within 15 minutes) and not freeze on non-transactional queries.

What did you see instead?

Migration freezes, -postgresql.transactional.lock=false does not work

@AlbertoEE
Copy link

I can confirm that this is also happening on the Flyway Docker Image as well.

@TheHenrick
Copy link
Author

I also posted for the docker image :)

You're right, the new default for transaction is set to null and isTransactionalLock always returns true. I see that @Barry-RG also added a method, setTransactionalLock, to set the value, but it is never used. I wonder if he simply forgot to connect it with the cli flags.

@Barry-RG
Copy link
Contributor

Barry-RG commented Jun 8, 2023

Thanks for your update. We have been making updates to the configuration of Flyway and it seems like this has become disconnected. We have already started a fix for this and will update soon.

@TheHenrick
Copy link
Author

9.19.4 is working for me, thanks guys for the quick fix!

@MrMaxxan
Copy link

I've tried with this previous minimal example and changing Flyway version to 9.19.4 or 9.21.1, but it still hangs when creating the index. Is there anything else that needs to be done to make it work?
https://github.com/AvaPL/flyway-postgres-concurrent-index-issue

@nantipov
Copy link

Following to message from @MrMaxxan, this behaviour is also reproducible in 9.22.1.
Should be this issue reopened?
@TheHenrick

@xsor-hbo
Copy link

Thanks for your update. We have been making updates to the configuration of Flyway and it seems like this has become disconnected. We have already started a fix for this and will update soon.

Has there been a fix yet?
Thanks!

@luhn
Copy link

luhn commented Oct 2, 2023

Also encountering this on 9.22.2

@luhn
Copy link

luhn commented Oct 2, 2023

My workaround is to add if not exists to the create index statement. Then I:

  • Run the migration.
  • It hangs.
  • Ctrl-C to cancel, which frees up the locks so create index can successfully run (despite the connection breaking)
  • Run the migration again, which skips the index (because it now exists) and completes successfully.

@elwaxoro
Copy link

Running into the forever hang on 9.22.1. Using workarounds from:
#3508
and
spring-projects/spring-boot#32629

@noobgramming
Copy link

We are also encountering this issue on 9.22.2

Reopen plz?

@gajus
Copy link

gajus commented Oct 24, 2023

Same issue on 9.22.3

@gajus
Copy link

gajus commented Oct 24, 2023

I've gone down all the way to version 9.6 and it still has this problem.

CC @DoodleBobBuffPants @juliahayward @Lyeeedar

@worldtiki
Copy link

Same issue here on 9.22.3.

@Austinito
Copy link

Facing this issue on 9.8.2

@topEngineerRay
Copy link

same issue on spring boot 3.2 + flyway 9.22.3. All the solutions here does not work for me.
Only by change the version backto 8.xx.x works...

@JasonLuo-Redgate
Copy link

To avoid this issue, two conditions need to be met:

  • Flyway 9.19.4 version or higher
  • postgresql.transactional.lock set to false

@luhn
Copy link

luhn commented Jan 30, 2024

There was a regression sometime around 9.22. I just encountered it this morning on 10.6.0 with flyway.postgresql.transactional.lock=false

@JasonLuo-Redgate
Copy link

I did another round of verification of this scenario with the latest version of Flyway:

  1. Run Migration with a sql script containing CREATE INDEX CONCURRENTLY on postgresql.
  2. Flyway hangs forever.
  3. Add flyway.postgresql.transactional.lock=false into the configuration file.
  4. Run Migration again with the same sql script. The migration completed successfully.

@luhn
Copy link

luhn commented Jan 31, 2024

Step 1+2 will successfully create the index (once flyway is terminated, the deadlock clears up and the creation succeeds), so step 3+4 will fail with "ERROR: relation ... already exists". I suspect you have IF NOT EXISTS on your index, which as I pointed out here is a workaround for the issue.

If you start the process with flyway.postgresql.transactional.lock=false, you should see the issue.

I am able to recreate this issue reliably, now in 10.7.1. https://gist.github.com/luhn/7688fb2545bb7bab59c4d7cd02ff3d15

@JasonLuo-Redgate
Copy link

Hi @luhn ,
Sorry for not being specific, I rebuilt the db environment between step 1+2 and step 3+4.

But I was able to reproduce the issue now with the configurations you have provided in the gist link. And I found out that it's due to the "# Issue with CREATE INDEX CONCURRENTLY" comment in the conf file.

Remove that comment or put it in a separated line, the issue will be gone.

@luhn
Copy link

luhn commented Feb 1, 2024

Huh, sure enough. Thanks for your help!

@ehsansad
Copy link

I am getting the same error with version 9.18.0 and I am setting the flyway.postgresql.transactional.lock=false in a separate .conf file before the flyway sql file. can this problem happen if you have several create index concurrenly .. in a single file?

@JasonLuo-Redgate
Copy link

Hi @ehsansad ,
First you might need Flyway 9.19.4 version or higher.

postgresql.transactional.lock is a global configuration, which will have an impact on all the migrations.

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

No branches or pull requests