Re: LogwrtResult contended spinlock

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org, Jaime Casanova <jaime.casanova@2ndquadrant.com>
Date: 2022-03-22T01:11:18Z
Lists: pgsql-hackers
Hi,

On 2021-11-22 18:56:43 -0300, Alvaro Herrera wrote:
> There was an earlier comment by Andres that asyncXactLSN should also be
> atomic, to avoid an ugly spinlock interaction with the new atomic-based
> logwrtResult.  The 0002 here is an attempt at doing that; I found that
> it also needed to change WalWriterSleeping to use atomics, to avoid
> XLogSetAsyncXactLSN having to grab the spinlock for that.

This patch currently doesn't apply: http://cfbot.cputube.org/patch_37_2716.log

Are you aiming this for v15? Otherwise I'd like to move the entry to the next
CF. Marked as waiting-on-author.

Greetings,

Andres Freund



Commits

  1. Remove bogus assertion in pg_atomic_monotonic_advance_u64

  2. Add XLogCtl->logInsertResult

  3. Operate XLogCtl->log{Write,Flush}Result with atomics

  4. Split XLogCtl->LogwrtResult into separate struct members

  5. Introduce atomic read/write functions with full barrier semantics.

  6. Reduce the number of GetFlushRecPtr() calls done by walsenders.

  7. Remove most volatile qualifiers from xlog.c