Re: Add progressive backoff to XactLockTableWait functions

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Cc: Kevin K Biju <kevinkbiju(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add progressive backoff to XactLockTableWait functions
Date: 2025-07-17 14:54:44
Message-ID: CABPTF7Vhh7aS9qpU6oBJ=iqS5zgNS5AhB6bLj-+hS6cMhgLvZg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

After studying proarray and lmgr more closely, I have found several
critical issues in the two patches and underestimated their complexity
and subtlety. Sorry for posting immature patches that may have created
noise.

I now realize that making lock acquisition— (void) LockAcquire(&tag,
ShareLock, false, false); in XactLockTableWait
work on a standby, following Andres’ first suggestion, may be simpler
and require fewer new helpers.

XactLockTableWait fails on a standby simply because we never call
XactLockTableInsert. I am considering invoking XactLockTableInsert
when an XID is added to KnownAssignedXids, and XactLockTableDelete(the
constraint for delete now is not used for main xid in primary) when it
is removed. A preliminary implementation and test shows this approach
kinda works, but still need to confirm it is safe on a standby and
does not break other things.

patched:
Performance counter stats for process id '2331196':

233,947,559 cycles
106,270,044 instructions # 0.45
insn per cycle
12,464,449 cache-misses
9,397 context-switches

60.001191369 seconds time elapsed

head:
Performance counter stats for process id '2435004':

1,258,615,994 cycles
575,248,830 instructions # 0.46
insn per cycle
72,508,027 cache-misses
43,791 context-switches

60.001040589 seconds time elapsed

Best,
Xuneng

Attachment Content-Type Size
flamegraph.svg image/svg+xml 58.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-07-17 15:32:10 Re: small fix for pg_overexplain docs
Previous Message Fujii Masao 2025-07-17 14:34:32 Re: Log prefix missing for subscriber log messages received from publisher