更新时PostgreSQL锁定问题

时间:2018-04-13 05:32:22

标签: postgresql locking deadlock

我对postgreSQL有一些性能问题,如果我用以下方法查询锁:

SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa
ON pl.pid = psa.pid WHERE virtualtransaction='13/309458';

我明白了:

locktype    database  relation  page  tuple virtualxid  transactionid classido  objid objsubid  virtualtransaction  pid mode  granted fastpath  datid datname pid usesysid  usename application_name  client_addr client_hostname client_port backend_start xact_start  query_start state_change  wait_event_type wait_event  state backend_xid backend_xmin  query
transactionid  5986031  13/309458   12718   ExclusiveLock   true    false   16404   peter   12718   16403   peter       35.195.100.216      42828   2018-04-13 07:07:29.948748  2018-04-13 07:08:55.717530  2018-04-13 07:08:55.923704  2018-04-13 07:08:55.923705  Lock    transactionid   active  5986031 5953002 update "users_rooms" set "lastContact" = $1 where "roomId" = $2 and "active" = $3
transactionid  5986018  13/309458   12718   ShareLock   false   false   16404   peter   12718   16403   peter       35.195.100.216      42828   2018-04-13 07:07:29.948748  2018-04-13 07:08:55.717530  2018-04-13 07:08:55.923704  2018-04-13 07:08:55.923705  Lock    transactionid   active  5986031 5953002 update "users_rooms" set "lastContact" = $1 where "roomId" = $2 and "active" = $3

我不知道如何阅读,但如果我尝试了解我有两次相同的更新,一次在我的交易中,另一次在其外。这意味着他们阻止了彼此? 你明白同样的事吗?

如果我试图查询他的活动锁,我就老了,这是正常的吗? enter image description here 谢谢

0 个答案:

没有答案