Exclusive Modes由于行级锁只是一个属性,所以队列的使用方式并不那么简单。当一个事务要去修改某行数据时,按照以下步骤执行:1.如果xmax和hint bits标明当前行被不兼容的模式锁定,那么该事务就会申请一个要修改的元组的重量级锁(元组锁,和row-level lock不一样)。2.如果有必要,请求xmax字段记录事务的ID锁(之前介绍过,
transactionid | 583 | 3/11 | 21144 | ExclusiveLock | t | f You can see the writer transaction id for locktype=transactionid == 583. Let’s get the pid and backend id for the holding lock: 1 2 3 4 5 postgres=# SELECT id,pg_backend_pid() FROM pg_stat_get_backend_idset() AS...
«normal» locks have yet to be used. If we need to wait for a row to be released, we actually need to wait until completion of the locking transaction: all locks are released at the transaction commit or roll back. And to this end, we can request a lock on the ID of the lock...
* Decode the locktag back to the original values, to avoid sending lots of empty bytes with every message. See lock.h to check how a locktag is defined for LOCKTAG_RELATION */ LogAccessExclusiveLock(locktag->locktag_field1, locktag->locktag_field2); } return LOCKACQUIRE_OK; } 1. ...