Fix showing XID of a spectoken lock in an incorrect field of pg_locks view.

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix showing XID of a spectoken lock in an incorrect field of pg_locks view.
Date: 2023-01-04 06:45:34
Message-ID: CAD21AoCEKxZztULP1CDm45aSNNR1QO-Bh1q6LMTspQ78PBuJrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 Content-Type Size
v1-0001-Fix-showing-transaction-id-of-a-spectoken-lock-in.patch application/octet-stream 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-01-04 06:47:40 Re: pgsql: Delay commit status checks until freezing executes.
Previous Message Peter Geoghegan 2023-01-04 06:41:35 Re: pgsql: Delay commit status checks until freezing executes.