Re: Add CHECK_FOR_INTERRUPTS in polling loop code path in XactLockTableWait
Xuneng Zhou <xunengzhou@gmail.com>
From: Xuneng Zhou <xunengzhou@gmail.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>,
Kevin K Biju <kevinkbiju@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-06-03T03:32:00Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Make XactLockTableWait() and ConditionalXactLockTableWait() interruptable more.
- 706344f06fbd 13.22 landed
- 9130d8eeebad 14.19 landed
- 405cca9daa42 15.14 landed
- 63fa7caa9588 16.10 landed
- 24c5ad5be46d 17.6 landed
- 961553daf5d6 18.0 landed
Attachments
- 0001-Add-wait-event-and-progressive-backoff-to-XactLockTable.patch (application/octet-stream) patch 0001
Hi all,
Thank you for the earlier pushed patch—after testing it, things work
well. Per Fujii’s and Kevin’s ideas and suggestions[1], [2], I’ve
tried to extend it to add a new wait event and a progressive backoff
mechanism for XactLockTableWait in logical replication scenarios.
New wait event
• XACT_DONE (“Waiting for a transaction to commit or abort”):
This shows up when a standby is blocked waiting for the primary’s XID replay.
Progressive backoff
• When XactLockTableWait is called from logical replication (oper ==
XLTW_None), the sleep interval doubles each loop up to one second.
• ConditionalXactLockTableWait still uses a fixed 1 ms sleep, since it
is only invoked by heap and index operations.
With the patch applied, a blocked slot‐creation session on standby now shows:
testdb=# SELECT pid, wait_event_type, wait_event, state, query FROM
pg_stat_activity WHERE pid = 62774;
pid | wait_event_type | wait_event | state |
query
-------+-----------------+------------+--------+------------------------------------------------------------------
62774 | IPC | XactDone | active | SELECT *
| | | | FROM
pg_create_logical_replication_slot('my_slot','pgoutput');
(1 row)
Please let me know if you have any feedback or suggestions.
[1] https://www.postgresql.org/message-id/422ea29f-2051-441c-aa5d-5eea04a81b95%40oss.nttdata.com
[2] https://www.postgresql.org/message-id/CAM45KeF6%2B3GtR7dDTAM-kwpGWpnUmAeg%3Djh0N3cd%3DNGBgvVkkA%40mail.gmail.com