1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Prevent concurrent SimpleLruTruncate() for any given SLRU.

The SimpleLruTruncate() header comment states the new coding rule.  To
achieve this, add locktype "frozenid" and two LWLocks.  This closes a
rare opportunity for data loss, which manifested as "apparent
wraparound" or "could not access status of transaction" errors.  Data
loss is more likely in pg_multixact, due to released branches' thin
margin between multiStopLimit and multiWrapLimit.  If a user's physical
replication primary logged ":  apparent wraparound" messages, the user
should rebuild standbys of that primary regardless of symptoms.  At less
risk is a cluster having emitted "not accepting commands" errors or
"must be vacuumed" warnings at some point.  One can test a cluster for
this data loss by running VACUUM FREEZE in every database.  Back-patch
to 9.5 (all supported versions).

Discussion: https://postgr.es/m/20190218073103.GA1434723@rfd.leadboat.com
This commit is contained in:
Noah Misch
2020-08-15 10:15:53 -07:00
parent 9d472b51e9
commit d4031d7846
11 changed files with 118 additions and 15 deletions

View File

@ -9005,7 +9005,8 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
and general database objects (identified by class OID and object OID,
in the same way as in <structname>pg_description</structname> or
<structname>pg_depend</structname>). Also, the right to extend a
relation is represented as a separate lockable object.
relation is represented as a separate lockable object, as is the right to
update <structname>pg_database</structname>.<structfield>datfrozenxid</structfield>.
Also, <quote>advisory</quote> locks can be taken on numbers that have
user-defined meanings.
</para>
@ -9031,6 +9032,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
Type of the lockable object:
<literal>relation</literal>,
<literal>extend</literal>,
<literal>frozenid</literal>,
<literal>page</literal>,
<literal>tuple</literal>,
<literal>transactionid</literal>,

View File

@ -849,7 +849,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<tbody>
<row>
<entry morerows="64"><literal>LWLock</literal></entry>
<entry morerows="66"><literal>LWLock</literal></entry>
<entry><literal>ShmemIndexLock</literal></entry>
<entry>Waiting to find or allocate space in shared memory.</entry>
</row>
@ -1047,6 +1047,16 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting to execute <function>txid_status</function> or update
the oldest transaction id available to it.</entry>
</row>
<row>
<entry><literal>WrapLimitsVacuumLock</literal></entry>
<entry>Waiting to update limits on transaction id and multixact
consumption.</entry>
</row>
<row>
<entry><literal>NotifyQueueTailLock</literal></entry>
<entry>Waiting to update limit on notification message
storage.</entry>
</row>
<row>
<entry><literal>clog</literal></entry>
<entry>Waiting for I/O on a clog (transaction status) buffer.</entry>
@ -1132,7 +1142,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
counters during Parallel Hash plan execution.</entry>
</row>
<row>
<entry morerows="9"><literal>Lock</literal></entry>
<entry morerows="10"><literal>Lock</literal></entry>
<entry><literal>relation</literal></entry>
<entry>Waiting to acquire a lock on a relation.</entry>
</row>
@ -1140,6 +1150,12 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry><literal>extend</literal></entry>
<entry>Waiting to extend a relation.</entry>
</row>
<row>
<entry><literal>frozenid</literal></entry>
<entry>Waiting to
update <structname>pg_database</structname>.<structfield>datfrozenxid</structfield>
and <structname>pg_database</structname>.<structfield>datminmxid</structfield>.</entry>
</row>
<row>
<entry><literal>page</literal></entry>
<entry>Waiting to acquire a lock on page of a relation.</entry>