Re: Add progressive backoff to XactLockTableWait functions

Xuneng Zhou <xunengzhou@gmail.com>

From: Xuneng Zhou <xunengzhou@gmail.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>, Andres Freund <andres@anarazel.de>
Cc: Kevin K Biju <kevinkbiju@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-07-03T02:19:49Z
Lists: pgsql-hackers
>
> Thanks for the feedbacks!

To be honest, I'm fine with v3, since it only increases the sleep time
> after 5000 loop iterations, which has negligible performance impact.
> But if these functions aren't intended to be used during recovery and
> the loop shouldn't reach that many iterations, I'm also okay with
> the v4 approach of introducing a separate function specifically for
> recovery.
>
> But this amakes me wonder if we should add something like
> Assert(!RecoveryInProgress()) to those two functions, to prevent them
> from being used during recovery in the future.
>
> > but it's hard to find a proper place for it to fit well: lmgr.c is for
> locks, while standby.c or procarray.c are not that ideal either. Therefore,
> I placed the special handling for standby in SnapBuildWaitSnapshot.
>
> Since the purpose and logic of the new function are similar to
> XactLockTableWait(), I think it would be better to place it nearby
> in lmgr.c, even though it doesn't handle a lock directly. That would
> help keep the related logic together and improve readability.
>


Now I see two possible approaches here. One is to extend
XactLockTableWait(), and the other is to introduce a new wait function
specifically for standby. For the first option, adding standby-specific
logic might not align well with the function’s name or its original design.
If we go with a new function, we might need to consider what other
scenarios it could be reused in. If this is the only place it would apply,
whether it’s worth introducing a separate function just for this case.

Best regards,
Xuneng

>

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Allow logical decoding on standbys