Flyway 4.1, 4.2 incompatible with Percona's PXC Strict Mode

623 Views Asked by At

After upgrading to Flyway 4.2.1 we started getting error during release to Percona MySQL cluster. The error we get is:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.dbsupport.FlywaySqlException: 
Unable to acquire MySQL named lock: Flyway-605484229
----------------------------------------------------
SQL State  : HY000
Error Code : 1105
Message    : Percona-XtraDB-Cluster prohibits use of GET_LOCK with pxc_strict_mode = ENFORCING

Looks like Flyway 4.1+ attempts to lock the table and Percona's PXC strict mode doesn't allow to do that.

I believe my question is: can we do something on Flyway 4.1+ side to avoid this error (everything worked fine in Flyway 4.0 before) or the only option we have is to disable PXC strict mode in Percona?

Thank you!

1

There are 1 best solutions below

0
On

Explicit locks in PXC are not distributed to the entire cluster. This can lead to unknown/undesirable consequences. Thus, in more modern versions of PXC, pxc_strict_mode was introduced to help prevent unintentional side effects from happening.

If your application isolates writes to only 1 node, you can change the setting to MASTER which keeps most enforcing behavior except for table lock checks.

It is a session-level variable as well, so changing it just for this operation will not affect other sessions.

On another note, if it worked in 4.0 and doesn't work in 4.1 and nothing has changed on the DB side, then it's an issue to raise with Flyway developers. It's clearly a feature/functionality they added and it should have come with an option to disable.