Prevent concurrent SimpleLruTruncate() for any given SLRU.
Noah Misch <noah@leadboat.com>
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
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/catalogs.sgml | modified | +3 −1 |
| doc/src/sgml/monitoring.sgml | modified | +18 −2 |
| src/backend/access/transam/slru.c | modified | +8 −0 |
| src/backend/access/transam/subtrans.c | modified | +2 −2 |
| src/backend/commands/async.c | modified | +27 −10 |
| src/backend/commands/vacuum.c | modified | +13 −0 |
| src/backend/storage/lmgr/lmgr.c | modified | +20 −0 |
| src/backend/storage/lmgr/lwlocknames.txt | modified | +3 −0 |
| src/backend/utils/adt/lockfuncs.c | modified | +12 −0 |
| src/include/storage/lmgr.h | modified | +3 −0 |
| src/include/storage/lock.h | modified | +10 −0 |
Documentation touched
Discussion
- SimpleLruTruncate() mutual exclusion 14 messages · 2019-02-18 → 2020-08-02