系统崩溃后,我的Postgresql数据库确实锁定了一行。
pg_locks
表包含许多没有pid的行。即。
select locktype,database,relation,virtualtransaction, pid,mode,granted from pg_locks p1;
locktype | database | relation | virtualtransaction | pid | mode | granted
---------------+----------+----------+--------------------+-------+------------------+---------
relation | 16408 | 31459 | -1/40059 | | AccessShareLock | t
relation | 16408 | 31459 | -1/40059 | | RowExclusiveLock | t
relation | 16408 | 31022 | -1/40060 | | AccessShareLock | t
transactionid | | | -1/40060 | | ExclusiveLock | t
relation | 16408 | 31485 | -1/40060 | | AccessShareLock | t
如何将事务40060杀死并删除锁?
答案 0 :(得分:3)
好的,我自己找到的解决方案:
select * from pg_prepared_xacts where transaction = 40060;
ROLLBACK PREPARED gid;
这将清除锁。