liquibase lock 无法在 postgresql docker Image 中获取更改日志锁

问题描述 投票:0回答:2

liquibase 锁定在 docker 中的 Postgrease

原因:liquibase.exception.LockException:无法获取 更改日志锁。目前被 85c1e0340e82 (172.18.0.12) 锁定 2020 年 6 月 18 日上午 11:36

Caused by: liquibase.exception.LockException: Could not acquire change log lock.  Currently locked by 85c1e0340e82 (172.18.0.12) since 6/18/20, 11:36 AM
        at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:236)
        at liquibase.Liquibase.update(Liquibase.java:184)
        at liquibase.Liquibase.update(Liquibase.java:179)
        at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:366)
        at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:314)
        at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
        at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
        at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.afterPropertiesSet(AsyncSpringLiquibase.java:103)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
        ... 16 common frames omitted
postgresql docker
2个回答
5
投票

经过一番研究:

我找到了解决方案。

找到docker镜像的详细信息。

%>  docker ps -a --filter "name=docker-compose"

%>. CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
b5b26f985       postgres:12.3       "docker-entrypoint.s…"   5 hours ago         Up 19 minutes       5432/tcp            docker-compose

进入图像环境

%> docker exec -it b5b26f985 bash 

%>root@b5b26f985:/# ls
root@b5b26f985:/# bin  boot  dev  docker-entrypoint-initdb.d  docker-entrypoint.sh  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

现在连接到PG

root@b5b26f985e9b:/# psql -h localhost -U <username >

<username >=# select * from DATABASECHANGELOGLOCK;
 id | locked |       lockgranted       |          lockedby          
----+--------+-------------------------+----------------------------
  1 | t      | 2020-06-18 11:36:08.825 | 85c1e0340e82 (172.18.0.12)
(1 row)

表锁定类型的描述我的更改形式系统到系统和 DB 到 DB 非常适合检查数据类型。

<username >=# \d DATABASECHANGELOGLOCK;
                    Table "public.databasechangeloglock"
   Column    |            Type             | Collation | Nullable | Default 
-------------+-----------------------------+-----------+----------+---------
 id          | integer                     |           | not null | 
 locked      | boolean                     |           | not null | 
 lockgranted | timestamp without time zone |           |          | 
 lockedby    | character varying(255)      |           |          | 
Indexes:
    "databasechangeloglock_pkey" PRIMARY KEY, btree (id)

更新查询

=# 更新 DATABASECHANGELOGLOCK 设置 LOCKED=false、LOCKGRANTED=null、LOCKEDBY=null 其中 ID=1;

UPDATE 1
<username >=# SELECT * FROM DATABASECHANGELOGLOCK;
 id | locked | lockgranted | lockedby 
----+--------+-------------+----------
  1 | f      |             | 
(1 row)

--现在尝试一下应该可以。快乐编码。


0
投票

就我而言,我在运行一些包含使用“SET”声明环境/会话变量的 Postgres 备份时遇到问题。

解决方案:尝试注释所有会话变量声明命令。它为我解决了问题:

-- SET client_encoding = 'UTF8';
-- SET standard_conforming_strings = on;
-- SET client_min_messages = warning;

配置:Postgres 14.5; Liquibase 4.5 与 Maven

© www.soinside.com 2019 - 2024. All rights reserved.