Commit 7e453634 authored by Amit Kapila's avatar Amit Kapila

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
parent 808e13b2
...@@ -188,7 +188,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer) ...@@ -188,7 +188,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
/* OK to prune */ /* OK to prune */
(void) heap_page_prune(relation, buffer, vistest, (void) heap_page_prune(relation, buffer, vistest,
limited_xmin, limited_ts, limited_xmin, limited_ts,
true, &ignore); true, &ignore, NULL);
} }
/* And release buffer lock */ /* And release buffer lock */
...@@ -213,6 +213,9 @@ heap_page_prune_opt(Relation relation, Buffer buffer) ...@@ -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 * send its own new total to pgstats, and we don't want this delta applied
* on top of that.) * 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 * Returns the number of tuples deleted from the page and sets
* latestRemovedXid. * latestRemovedXid.
*/ */
...@@ -221,7 +224,8 @@ heap_page_prune(Relation relation, Buffer buffer, ...@@ -221,7 +224,8 @@ heap_page_prune(Relation relation, Buffer buffer,
GlobalVisState *vistest, GlobalVisState *vistest,
TransactionId old_snap_xmin, TransactionId old_snap_xmin,
TimestampTz old_snap_ts, TimestampTz old_snap_ts,
bool report_stats, TransactionId *latestRemovedXid) bool report_stats, TransactionId *latestRemovedXid,
OffsetNumber *off_loc)
{ {
int ndeleted = 0; int ndeleted = 0;
Page page = BufferGetPage(buffer); Page page = BufferGetPage(buffer);
...@@ -262,6 +266,13 @@ heap_page_prune(Relation relation, Buffer buffer, ...@@ -262,6 +266,13 @@ heap_page_prune(Relation relation, Buffer buffer,
if (prstate.marked[offnum]) if (prstate.marked[offnum])
continue; 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 */ /* Nothing to do if slot is empty or already dead */
itemid = PageGetItemId(page, offnum); itemid = PageGetItemId(page, offnum);
if (!ItemIdIsUsed(itemid) || ItemIdIsDead(itemid)) if (!ItemIdIsUsed(itemid) || ItemIdIsDead(itemid))
...@@ -271,6 +282,10 @@ heap_page_prune(Relation relation, Buffer buffer, ...@@ -271,6 +282,10 @@ heap_page_prune(Relation relation, Buffer buffer,
ndeleted += heap_prune_chain(buffer, offnum, &prstate); 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 */ /* Any error while applying the changes is critical */
START_CRIT_SECTION(); START_CRIT_SECTION();
......
This diff is collapsed.
...@@ -178,7 +178,8 @@ extern int heap_page_prune(Relation relation, Buffer buffer, ...@@ -178,7 +178,8 @@ extern int heap_page_prune(Relation relation, Buffer buffer,
struct GlobalVisState *vistest, struct GlobalVisState *vistest,
TransactionId limited_oldest_xmin, TransactionId limited_oldest_xmin,
TimestampTz limited_oldest_ts, TimestampTz limited_oldest_ts,
bool report_stats, TransactionId *latestRemovedXid); bool report_stats, TransactionId *latestRemovedXid,
OffsetNumber *off_loc);
extern void heap_page_prune_execute(Buffer buffer, extern void heap_page_prune_execute(Buffer buffer,
OffsetNumber *redirected, int nredirected, OffsetNumber *redirected, int nredirected,
OffsetNumber *nowdead, int ndead, OffsetNumber *nowdead, int ndead,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment