summaryrefslogtreecommitdiff
path: root/src/include/storage/lmgr.h
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2020-08-15 10:15:53 -0700
committerNoah Misch <noah@leadboat.com>2020-08-15 10:15:57 -0700
commit3fbbf64ceecbd0fe675850070ea1e5d77c401c4f (patch)
tree9e7021dbabf53488b004337a94ca2c4a66fed09d /src/include/storage/lmgr.h
parent5190707d7436089a33dd0e83482a314333ab6e59 (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.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h
index e7ccce22942..72d112ee44e 100644
--- a/src/include/storage/lmgr.h
+++ b/src/include/storage/lmgr.h
@@ -54,6 +54,9 @@ extern void UnlockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode);
extern void LockRelationForExtension(Relation relation, LOCKMODE lockmode);
extern void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode);
+/* 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);