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

Attachment: 0001-Add-wait-event-and-progressive-backoff-to-XactLockTable.patch
Description: Binary data

Reply via email to