mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Clear all-frozen visibilitymap status when locking tuples.
Sincea892234
&fd31cd265
the visibilitymap's freeze bit is used to avoid vacuuming the whole relation in anti-wraparound vacuums. Doing so correctly relies on not adding xids to the heap without also unsetting the visibilitymap flag. Tuple locking related code has not done so. To allow selectively resetting all-frozen - to avoid pessimizing heap_lock_tuple - allow to selectively reset the all-frozen with visibilitymap_clear(). To avoid having to use visibilitymap_get_status (e.g. via VM_ALL_FROZEN) inside a critical section, have visibilitymap_clear() return whether any bits have been reset. There's a remaining issue (denoted by XXX): After the PageIsAllVisible() check in heap_lock_tuple() and heap_lock_updated_tuple_rec() the page status could theoretically change. Practically that currently seems impossible, because updaters will hold a page level pin already. Due to the next beta coming up, it seems better to get the required WAL magic bump done before resolving this issue. The added flags field fields to xl_heap_lock and xl_heap_lock_updated require bumping the WAL magic. Since there's already been a catversion bump since the last beta, that's not an issue. Reviewed-By: Robert Haas, Amit Kapila and Andres Freund Author: Masahiko Sawada, heavily revised by Andres Freund Discussion: CAEepm=3fWAbWryVW9swHyLTY4sXVf0xbLvXqOwUoDiNCx9mBjQ@mail.gmail.com Backpatch: -
This commit is contained in:
@ -243,15 +243,19 @@ typedef struct xl_heap_cleanup_info
|
||||
#define XLHL_XMAX_KEYSHR_LOCK 0x08
|
||||
#define XLHL_KEYS_UPDATED 0x10
|
||||
|
||||
/* flag bits for xl_heap_lock / xl_heap_lock_updated's flag field */
|
||||
#define XLH_LOCK_ALL_FROZEN_CLEARED 0x01
|
||||
|
||||
/* This is what we need to know about lock */
|
||||
typedef struct xl_heap_lock
|
||||
{
|
||||
TransactionId locking_xid; /* might be a MultiXactId not xid */
|
||||
OffsetNumber offnum; /* locked tuple's offset on page */
|
||||
int8 infobits_set; /* infomask and infomask2 bits to set */
|
||||
uint8 flags; /* XLH_LOCK_* flag bits */
|
||||
} xl_heap_lock;
|
||||
|
||||
#define SizeOfHeapLock (offsetof(xl_heap_lock, infobits_set) + sizeof(int8))
|
||||
#define SizeOfHeapLock (offsetof(xl_heap_lock, flags) + sizeof(int8))
|
||||
|
||||
/* This is what we need to know about locking an updated version of a row */
|
||||
typedef struct xl_heap_lock_updated
|
||||
@ -259,9 +263,10 @@ typedef struct xl_heap_lock_updated
|
||||
TransactionId xmax;
|
||||
OffsetNumber offnum;
|
||||
uint8 infobits_set;
|
||||
uint8 flags;
|
||||
} xl_heap_lock_updated;
|
||||
|
||||
#define SizeOfHeapLockUpdated (offsetof(xl_heap_lock_updated, infobits_set) + sizeof(uint8))
|
||||
#define SizeOfHeapLockUpdated (offsetof(xl_heap_lock_updated, flags) + sizeof(uint8))
|
||||
|
||||
/* This is what we need to know about confirmation of speculative insertion */
|
||||
typedef struct xl_heap_confirm
|
||||
|
Reference in New Issue
Block a user