We had a task which was stuck so I used SELECT pg_cancel_backend(<pid of the process>)
to kill the task. However the lock that the task hold didn't go away and now one of my table is locked.
I am trying to run a COPY
command on the table and it gets stuck with wait_event_type = Lock
.
System being Used:
Server: AWS RDS db.m4.xlarge
DB: PostgreSQL 9.6.6
select * from pg_locks;
locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
--------------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+-------+------------------+---------+----------
relation | 16390 | 19694 | | | | | | | | -1/24019935 | | RowExclusiveLock | t | f
transactionid | | | | | | 24019935 | | | | -1/24019935 | | ExclusiveLock | t | f
select * from pg_prepared_xacts where transaction=24019935;
transaction | gid | prepared | owner | database
------------+------------------------------+------------------------------+----------+----------
24019935 | PGDIRTY:dirty_state::9994733 | 2018-06-27 13:40:12.88981-08 | postgres | pg
I already tried doing the step suggested in Remove locks without a pid in postgres, but it doesn't show any pgid.
I also tried rebooting my database but the lock still persists.
Can anyone help me figure out how to get rid of this lock ?
Thanks