Database locked in postgresdb

Document ID : KB000126722
Last Modified Date : 12/02/2019
Show Technical Document Details
Issue:
See the following messages in portal_portal-enterprise container logs 

: Waiting for changelog lock....
portal_portal-enterprise.0.uuw52yhtpq1p@hostname| 2019-02-12 06:31:51.094 INFO 1 --- [ main] liquibase : Waiting for changelog lock....
portal_portal-enterprise.0.uuw52yhtpq1p@hostname | 2019-02-12 06:32:01.099 INFO 1 --- [ main] liquibase : Waiting for changelog lock....
Environment:
API Portal 4.2.x
Default Postgres database
Cause:
On in-proper power-down and restore the database log lock status can be in set in an unavailable state.  

 
Resolution:
Connected to the docker container which is not starting.

docker exec -it <containerid> sh

/ # psql -U admin
Password for user admin:
psql (9.6.10)
Type "help" for help.

admin=# \c rbac
You are now connected to database "rbac" as user "admin".
rbac=# SELECT * FROM DATABASECHANGELOGLOCK;

Check for lock record with the Portal container IP.

Run this command to release the lock
UPDATE DATABASECHANGELOGLOCK SET locked='false', lockgranted=null, lockedby=null WHERE id=1;
 
Additional Information:
All databases should be checked for LOGLOCK entries. The above example is for rbac database.
Once logged on to psql, run \l command to list all available databases.