Hi,
> Some changes in v10:
>
> 1) XidWaitHashLock is used for all operations on XidWaitHash though
> might be unnecessary for some cases.
> 2) Field pg_atomic_uint32 waiter_count was removed from the
> XidWaitEntry. The start process now takes charge of cleaning up the
> XidWaitHash entry after waking up processes.
> 3) pg_atomic_uint32 xidWaiterNum is added to avoid unnecessary lock
> acquire & release and htab look-up while there's no xid waiting.
>
> Hope this could eliminate some subtleties.
>
> Exponential backoff in earlier patches is simple and effective for
> alleviating cpu overhead in extended waiting; however it could also
> bring unwanted latency for more sensitive use cases like logical
> walsender on cascading standbys. Unfortunately, I am unable to come up
> with a solution that is correct, effective and simple in all cases.
>
v11 removed this erroneous optimization:
3) pg_atomic_uint32 xidWaiterNum is added to avoid unnecessary lock
> acquire & release and htab look-up while there's no xid waiting.
Best,
Xuneng