Hi,

I realized that pg_locks view shows the transaction id of a
speculative token lock in the database field:

postgres(1:509389)=# select * from pg_locks where locktype = 'spectoken';
 locktype  | database | relation | page | tuple | virtualxid |
transactionid | classid | objid | objsubid | virtualtransaction |  pid
  |     mode      | granted | fastpath | waitstart
-----------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+--------+---------------+---------+----------+-----------
 spectoken |      741 |          |      |       |            |
      |       3 |     0 |        0 | 3/5                | 509314 |
ExclusiveLock | t       | f        |
(1 row)

It seems to be confusing and the user won't get the result even if
they search it by transactionid = 741. So I've attached the patch to
fix it. With the patch, the pg_locks views shows like:

 locktype  | database | relation | page | tuple | virtualxid |
transactionid | classid | objid | objsubid | virtualtransaction |  pid
  |     mode      | granted | fastpath | waitstart
-----------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+--------+---------------+---------+----------+-----------
 spectoken |          |          |      |       |            |
  746 |         |     1 |          | 3/4                | 535618 |
ExclusiveLock | t       | f        |
(1 row)

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment: v1-0001-Fix-showing-transaction-id-of-a-spectoken-lock-in.patch
Description: Binary data

Reply via email to