diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 3bef0e1..58bc3df 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -389,7 +389,7 @@ static LVSharedIndStats *get_indstats(LVShared *lvshared, int n);
 static bool skip_parallel_vacuum_index(Relation indrel, LVShared *lvshared);
 static void vacuum_error_callback(void *arg);
 static void update_vacuum_error_info(LVRelStats *errinfo, int phase,
-									 BlockNumber blkno, char *indname);
+									 BlockNumber blkno);
 
 
 /*
@@ -539,7 +539,7 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params,
 		 * revert to the previous phase.
 		 */
 		update_vacuum_error_info(vacrelstats, VACUUM_ERRCB_PHASE_TRUNCATE,
-								 vacrelstats->nonempty_pages, NULL);
+								 vacrelstats->nonempty_pages);
 		lazy_truncate_heap(onerel, vacrelstats);
 	}
 
@@ -949,7 +949,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
 		pgstat_progress_update_param(PROGRESS_VACUUM_HEAP_BLKS_SCANNED, blkno);
 
 		update_vacuum_error_info(vacrelstats, VACUUM_ERRCB_PHASE_SCAN_HEAP,
-								 blkno, NULL);
+								 blkno);
 
 		if (blkno == next_unskippable_block)
 		{
@@ -1829,7 +1829,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
 	/* Update error traceback information */
 	olderrinfo = *vacrelstats;
 	update_vacuum_error_info(vacrelstats, VACUUM_ERRCB_PHASE_VACUUM_HEAP,
-							 InvalidBlockNumber, NULL);
+							 InvalidBlockNumber);
 
 	pg_rusage_init(&ru0);
 	npages = 0;
@@ -1881,8 +1881,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
 	/* Revert to the previous phase information for error traceback */
 	update_vacuum_error_info(vacrelstats,
 							 olderrinfo.phase,
-							 olderrinfo.blkno,
-							 olderrinfo.indname);
+							 olderrinfo.blkno);
 }
 
 /*
@@ -1912,7 +1911,7 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
 	/* Update error traceback information */
 	olderrinfo = *vacrelstats;
 	update_vacuum_error_info(vacrelstats, VACUUM_ERRCB_PHASE_VACUUM_HEAP,
-							 blkno, NULL);
+							 blkno);
 
 	START_CRIT_SECTION();
 
@@ -1993,8 +1992,7 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
 	/* Revert to the previous phase information for error traceback */
 	update_vacuum_error_info(vacrelstats,
 							 olderrinfo.phase,
-							 olderrinfo.blkno,
-							 olderrinfo.indname);
+							 olderrinfo.blkno);
 	return tupindex;
 }
 
@@ -2418,10 +2416,16 @@ lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats,
 
 	/* Update error traceback information */
 	olderrinfo = *vacrelstats;
+
+	/*
+	 * The index name is saved only during this phase and restored immediately
+	 * after this phase.  See vacuum_error_callback.
+	 */
+	Assert(vacrelstats->indname == NULL);
+	vacrelstats->indname = pstrdup(RelationGetRelationName(indrel));
 	update_vacuum_error_info(vacrelstats,
 							 VACUUM_ERRCB_PHASE_VACUUM_INDEX,
-							 InvalidBlockNumber,
-							 RelationGetRelationName(indrel));
+							 InvalidBlockNumber);
 
 	/* Do bulk deletion */
 	*stats = index_bulk_delete(&ivinfo, *stats,
@@ -2441,8 +2445,9 @@ lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats,
 	/* Revert to the previous phase information for error traceback */
 	update_vacuum_error_info(vacrelstats,
 							 olderrinfo.phase,
-							 olderrinfo.blkno,
-							 olderrinfo.indname);
+							 olderrinfo.blkno);
+	pfree(vacrelstats->indname);
+	vacrelstats->indname = NULL;
 }
 
 /*
@@ -2474,18 +2479,26 @@ lazy_cleanup_index(Relation indrel,
 
 	/* Update error traceback information */
 	olderrcbarg = *vacrelstats;
+
+	/*
+	 * The index name is saved only during this phase and restored immediately
+	 * after this phase.  See vacuum_error_callback.
+	 */
+	Assert(vacrelstats->indname == NULL);
+	vacrelstats->indname = pstrdup(RelationGetRelationName(indrel));
 	update_vacuum_error_info(vacrelstats,
 							 VACUUM_ERRCB_PHASE_INDEX_CLEANUP,
-							 InvalidBlockNumber,
-							 RelationGetRelationName(indrel));
+							 InvalidBlockNumber);
 
 	*stats = index_vacuum_cleanup(&ivinfo, *stats);
 
 	/* Revert back to the old phase information for error traceback */
 	update_vacuum_error_info(vacrelstats,
 							 olderrcbarg.phase,
-							 olderrcbarg.blkno,
-							 olderrcbarg.indname);
+							 olderrcbarg.blkno);
+	pfree(vacrelstats->indname);
+	vacrelstats->indname = NULL;
+
 	if (!(*stats))
 		return;
 
@@ -3598,18 +3611,10 @@ vacuum_error_callback(void *arg)
 	}
 }
 
-/* Update vacuum error callback for the current phase, block, and index. */
+/* Update vacuum error callback for the current phase and block. */
 static void
-update_vacuum_error_info(LVRelStats *errinfo, int phase, BlockNumber blkno,
-						 char *indname)
+update_vacuum_error_info(LVRelStats *errinfo, int phase, BlockNumber blkno)
 {
 	errinfo->blkno = blkno;
 	errinfo->phase = phase;
-
-	/* Free index name from any previous phase */
-	if (errinfo->indname)
-		pfree(errinfo->indname);
-
-	/* For index phases, save the name of the current index for the callback */
-	errinfo->indname = indname ? pstrdup(indname) : NULL;
 }
