diff --git b/src/backend/access/heap/heapam.c a/src/backend/access/heap/heapam.c
index d309dd3..3dd6910 100644
--- b/src/backend/access/heap/heapam.c
+++ a/src/backend/access/heap/heapam.c
@@ -9490,16 +9490,16 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
 		if (warm_update)
 			HeapTupleHeaderSetWarmUpdated(htup);
 
-		offnum = PageAddItem(page, (Item) htup, newlen, offnum, true, true);
-		if (offnum == InvalidOffsetNumber)
-			elog(PANIC, "failed to add tuple");
-
 		/*
 		 * Make sure the tuple is marked as the latest and root offset
 		 * information is restored.
 		 */
 		HeapTupleHeaderSetHeapLatest(htup, xlrec->root_offnum);
 
+		offnum = PageAddItem(page, (Item) htup, newlen, offnum, true, true);
+		if (offnum == InvalidOffsetNumber)
+			elog(PANIC, "failed to add tuple");
+
 		if (xlrec->flags & XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED)
 			PageClearAllVisible(page);
 
diff --git b/src/include/access/htup_details.h a/src/include/access/htup_details.h
index ff22113..87b77eb 100644
--- b/src/include/access/htup_details.h
+++ a/src/include/access/htup_details.h
@@ -557,6 +557,7 @@ HeapTupleHeaderSetHeapLatest(HeapTupleHeader tup, Offset offnum)
 	Assert(OffsetNumberIsValid(offnum));
 
 	tup->t_infomask2 |= HEAP_LATEST_TUPLE;
+	Assert(OffsetNumberIsValid(offnum));
 	ItemPointerSetOffsetNumber(&tup->t_ctid, offnum);
 }
 
@@ -630,7 +631,7 @@ static inline void
 HeapTupleHeaderSetNextTid(HeapTupleHeader tup, ItemPointer tid)
 {
 	ItemPointerCopy(tid, &(tup->t_ctid));
-
+	Assert(ItemPointerIsValid(tid));
 	HeapTupleHeaderClearHeapLatest(tup);
 }
 
