Re: LogwrtResult contended spinlock
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@lists.postgresql.org,Alvaro Herrera
<alvherre@2ndquadrant.com>,Pg Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Jaime Casanova <jaime.casanova@2ndQuadrant.com>
Date: 2020-08-31T18:29:38Z
Lists: pgsql-hackers
Hi, On August 31, 2020 11:21:56 AM PDT, Alvaro Herrera <alvherre@2ndquadrant.com> wrote: >Jaime Casanova recently reported a situation where pglogical >replicating >from 64 POS sites to a single central (64-core) node, each with two >replication sets, causes XLog's info_lck to become highly contended >because of frequently reading LogwrtResult. We tested the simple fix >of >adding a new LWLock that protects LogwrtResult and LogwrtRqst; that >seems to solve the problem easily enough. > >At first I wanted to make the new LWLock cover only LogwrtResult >proper, >and leave LogwrtRqst alone. However on doing it, it seemed that that >might change the locking protocol in a nontrivial way. So I decided to >make it cover both and call it a day. We did verify that the patch >solves the reported problem, at any rate. Wouldn't the better fix here be to allow reading of individual members without a lock? E.g. by wrapping each in a 64bit atomic. Andres -- Sent from my Android device with K-9 Mail. Please excuse my brevity.
Commits
-
Remove bogus assertion in pg_atomic_monotonic_advance_u64
- 768f0c3e21b3 18.0 landed
- 3a9d0d774d90 17.0 landed
-
Add XLogCtl->logInsertResult
- f3ff7bf83bce 17.0 cited
-
Operate XLogCtl->log{Write,Flush}Result with atomics
- ee1cbe806dad 17.0 landed
-
Split XLogCtl->LogwrtResult into separate struct members
- c9920a9068ea 17.0 landed
-
Introduce atomic read/write functions with full barrier semantics.
- bd5132db558b 17.0 cited
-
Reduce the number of GetFlushRecPtr() calls done by walsenders.
- e369f3708636 13.0 cited
-
Remove most volatile qualifiers from xlog.c
- 6ba4ecbf477e 9.5.0 cited