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

Migrations that concurrently create indices hang in Flyway 9.1.2 #96

Closed
nickelsen opened this issue Sep 16, 2022 · 2 comments
Closed

Migrations that concurrently create indices hang in Flyway 9.1.2 #96

nickelsen opened this issue Sep 16, 2022 · 2 comments

Comments

@nickelsen
Copy link

Hi. After upgrading from Flyway 9.0.3 to 9.1.2, a migration that concurrently creates an index hangs in the preparer.

The behavior can be seen in the two commits here: https://github.com/nickelsen/embedded-postgres-flyway-test

I'm not sure if Flyway 9 is supported in the first place, but it works for us on Flyway 9.0.3.

In 9.1.2, Flyway switched from session locks to transactional locks in Postgres, which I think causes this hanging.

We're supposed to be able to turn off transactional locks through configuration, but as far as I can tell, the preparer just uses default configuration and cannot be configured using API or configuration files.

I've unsuccessfully attempted to override the configuration through the environment variable described here: https://flywaydb.org/documentation/configuration/parameters/postgresqlTransactionalLock

Writing this, I realized that we can go around the preparer and set the config on the API, so I added a commit demonstrating that in the above repo.

I'm not sure if this is relevant here or needs to be addressed in flyway-core, but this issue prevents us from using the FlywayPreparer so we have had to create our own preparer.

@tomix26
Copy link
Collaborator

tomix26 commented Nov 12, 2022

Hi @nickelsen, thanks for the comprehensive description of the problem. I'll take a look at it as soon as I can.

tomix26 added a commit that referenced this issue Dec 9, 2022
@tomix26
Copy link
Collaborator

tomix26 commented Dec 11, 2022

Ok, based on your report, I've extended the FlywayPreparer by a new factory method accepting a configuration map. So it should be possible to disable the transactional lock or change any other configuration. See the example below.

FlywayPreparer preparer = FlywayPreparer.fromConfiguration(Map.of(
             "flyway.locations", "db/migration",
             "flyway.postgresql.transactional.lock", "false"));

Regarding the second question, whether the problem is related to this library or the Flyway project, I found the following issue: flyway/flyway#3508. So I don't suppose the problem is caused by this project.

tomix26 added a commit that referenced this issue Dec 11, 2022
#96 Extend FlywayPreparer by a new fromConfiguration factory method
@tomix26 tomix26 added this to the 2.0.3 milestone Dec 11, 2022
@tomix26 tomix26 closed this as completed Dec 11, 2022
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

2 participants