gpt4 book ai didi

spring-boot - 无法获取表锁 - 另一个 Flyway 实例可能正在运行

转载 作者:行者123 更新时间:2023-12-02 19:14:01 26 4
gpt4 key购买 nike

我正在使用 Spring Boot 和 Flyway (6.5.5) 的集成来运行 CockroachDB 集群的更新。当多个服务实例同时启动时,所有实例都会尝试锁定flyway_schema_history表以验证迁移。但是,出现以下异常:

2020-09-09 00:00:00.013 ERROR 1 --- [           main] o.s.boot.SpringApplication               :
Application run failed 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.api.FlywayException:
Unable to obtain table lock - another Flyway instance may be running

我找不到任何配置属性来调整它。也许有人遇到过同样的问题并以某种方式解决了它?

解决方法:重新启动服务。

最佳答案

调试问题后,它出现了非常奇怪的 Flyway 行为:org.flywaydb.core.internal.database.cockroachdb.CockroachDBTable


CockroachDB-specific table.
Note that CockroachDB doesn't support table locks. We therefore use a row in the schema history as a lock indicator;
if another process ahs inserted such a row we wait (potentially indefinitely) for it to be removed before
carrying out a migration.
*/

因此,就我而言,在应用迁移期间,服务被重新启动,并且该伪锁定记录永远保留。

解决方法是手动删除“锁定”:

  installed_rank |             version              |               description                | type |                      script                      |  checksum   |    installed_by    |           installed_on           | execution_time | success
-----------------+----------------------------------+------------------------------------------+------+--------------------------------------------------+-------------+--------------------+----------------------------------+----------------+----------
-100 | d9ab17626a4d66a4d8a89fe9bdca98e9 | flyway-lock | | | 0 | | 2020-09-14 11:25:02.874838+00:00 | 0 | true

希望,它会对某人有所帮助。

已创建相应的票证:https://github.com/flyway/flyway/issues/2932

关于spring-boot - 无法获取表锁 - 另一个 Flyway 实例可能正在运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63915775/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com