diff options
| author | Andres Freund | 2016-07-18 09:01:13 +0000 |
|---|---|---|
| committer | Andres Freund | 2016-07-18 09:01:13 +0000 |
| commit | eca0f1db14ac92d91d54eca8eeff2d15ccd797fa (patch) | |
| tree | 293bb9becbd0ca0b53c00816fa7bdd6f08d94f02 /src/include | |
| parent | 65632082b7eb3c7d56f1b42e1df452d0f66bc189 (diff) | |
Clear all-frozen visibilitymap status when locking tuples.
Since a892234 & 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: -
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/heapam_xlog.h | 9 | ||||
| -rw-r--r-- | src/include/access/visibilitymap.h | 4 | ||||
| -rw-r--r-- | src/include/access/xlog_internal.h | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h index a822d0b82dc..06a82426bb5 100644 --- a/src/include/access/heapam_xlog.h +++ b/src/include/access/heapam_xlog.h @@ -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 diff --git a/src/include/access/visibilitymap.h b/src/include/access/visibilitymap.h index fca99ca318d..00bbd4c2d94 100644 --- a/src/include/access/visibilitymap.h +++ b/src/include/access/visibilitymap.h @@ -34,8 +34,8 @@ #define VM_ALL_FROZEN(r, b, v) \ ((visibilitymap_get_status((r), (b), (v)) & VISIBILITYMAP_ALL_FROZEN) != 0) -extern void visibilitymap_clear(Relation rel, BlockNumber heapBlk, - Buffer vmbuf); +extern bool visibilitymap_clear(Relation rel, BlockNumber heapBlk, + Buffer vmbuf, uint8 flags); extern void visibilitymap_pin(Relation rel, BlockNumber heapBlk, Buffer *vmbuf); extern bool visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf); diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 2627519ba08..0a595ccc481 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -31,7 +31,7 @@ /* * Each page of XLOG file has a header like this: */ -#define XLOG_PAGE_MAGIC 0xD092 /* can be used as WAL version indicator */ +#define XLOG_PAGE_MAGIC 0xD093 /* can be used as WAL version indicator */ typedef struct XLogPageHeaderData { |
