Liquibase锁定:在PostgreSQL Docker镜像中无法获取更改日志锁定

3

在docker中的Postgrease中锁定liquibase

由于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
1个回答

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)
锁定类型的描述可能因系统和数据库而异,检查数据类型很重要。
<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)

--现在可以尝试,应该可以正常工作。祝您编程愉快。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接