diff options
author | Noah Misch <noah@leadboat.com> | 2020-08-15 10:15:53 -0700 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2020-08-15 10:15:56 -0700 |
commit | 30e68a2abb3890c3292ff0b2422a7ea04d62acdd (patch) | |
tree | f4abe39532c9db31c78114d94d6b08584e551e16 /src/include/storage/lmgr.h | |
parent | 912fb290c5dd087ccc4b04c19692137bb786a9fd (diff) |
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
Diffstat (limited to 'src/include/storage/lmgr.h')
-rw-r--r-- | src/include/storage/lmgr.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h index 099e18f2b75..3f42000bda8 100644 --- a/src/include/storage/lmgr.h +++ b/src/include/storage/lmgr.h @@ -59,6 +59,9 @@ extern bool ConditionalLockRelationForExtension(Relation relation, LOCKMODE lockmode); extern int RelationExtensionLockWaiterCount(Relation relation); +/* Lock to recompute pg_database.datfrozenxid in the current database */ +extern void LockDatabaseFrozenIds(LOCKMODE lockmode); + /* Lock a page (currently only used within indexes) */ extern void LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); extern bool ConditionalLockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); |