aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/pruneheap.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2020-08-26 09:40:52 +0530
committerAmit Kapila <akapila@postgresql.org>2020-08-26 09:40:52 +0530
commit7e453634bb62f06a048f5562ba59d52aa1f28d12 (patch)
tree94a406f8d1b748fa98dff44ff5e4faa427c0d7a7 /src/backend/access/heap/pruneheap.c
parent808e13b282efa7e7ac7b78e886aca5684f4bccd3 (diff)
downloadpostgresql-7e453634bb62f06a048f5562ba59d52aa1f28d12.tar.gz
postgresql-7e453634bb62f06a048f5562ba59d52aa1f28d12.zip
Add additional information in the vacuum error context.
The additional information added will be an offset number for heap operations. This information will help us in finding the exact tuple due to which the error has occurred. Author: Mahendra Singh Thalor and Amit Kapila Reviewed-by: Sawada Masahiko, Justin Pryzby and Amit Kapila Discussion: https://postgr.es/m/CAKYtNApK488TDF4bMbw+1QH8HJf9cxdNDXquhU50TK5iv_FtCQ@mail.gmail.com
Diffstat (limited to 'src/backend/access/heap/pruneheap.c')
-rw-r--r--src/backend/access/heap/pruneheap.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index 3ad4222cb8a..bc510e2e9b3 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -188,7 +188,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
/* OK to prune */
(void) heap_page_prune(relation, buffer, vistest,
limited_xmin, limited_ts,
- true, &ignore);
+ true, &ignore, NULL);
}
/* And release buffer lock */
@@ -213,6 +213,9 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
* send its own new total to pgstats, and we don't want this delta applied
* on top of that.)
*
+ * off_loc is the offset location required by the caller to use in error
+ * callback.
+ *
* Returns the number of tuples deleted from the page and sets
* latestRemovedXid.
*/
@@ -221,7 +224,8 @@ heap_page_prune(Relation relation, Buffer buffer,
GlobalVisState *vistest,
TransactionId old_snap_xmin,
TimestampTz old_snap_ts,
- bool report_stats, TransactionId *latestRemovedXid)
+ bool report_stats, TransactionId *latestRemovedXid,
+ OffsetNumber *off_loc)
{
int ndeleted = 0;
Page page = BufferGetPage(buffer);
@@ -262,6 +266,13 @@ heap_page_prune(Relation relation, Buffer buffer,
if (prstate.marked[offnum])
continue;
+ /*
+ * Set the offset number so that we can display it along with any
+ * error that occurred while processing this tuple.
+ */
+ if (off_loc)
+ *off_loc = offnum;
+
/* Nothing to do if slot is empty or already dead */
itemid = PageGetItemId(page, offnum);
if (!ItemIdIsUsed(itemid) || ItemIdIsDead(itemid))
@@ -271,6 +282,10 @@ heap_page_prune(Relation relation, Buffer buffer,
ndeleted += heap_prune_chain(buffer, offnum, &prstate);
}
+ /* Clear the offset information once we have processed the given page. */
+ if (off_loc)
+ *off_loc = InvalidOffsetNumber;
+
/* Any error while applying the changes is critical */
START_CRIT_SECTION();