diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index f3da40a..c43ebbf 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -795,6 +795,10 @@ TrimCLOG(void)
 		int			slotno;
 		char	   *byteptr;
 
+		/* hack for pg_resetwal moving us to the middle of a page */
+		if (!SimpleLruDoesPhysicalPageExist(XactCtl, pageno))
+			SimpleLruZeroPage(XactCtl, pageno);
+
 		slotno = SimpleLruReadPage(XactCtl, pageno, false, xid);
 		byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index ce84dac..ed47ce0 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2042,6 +2042,10 @@ TrimMultiXact(void)
 		int			slotno;
 		MultiXactOffset *offptr;
 
+		/* hack for pg_resetwal moving us to the middle of a page */
+		if (!SimpleLruDoesPhysicalPageExist(MultiXactOffsetCtl, pageno))
+			SimpleLruZeroPage(MultiXactOffsetCtl, pageno);
+
 		slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, nextMXact);
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index 2334418..454ff8b 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -434,6 +434,8 @@ main(int argc, char *argv[])
 			FullTransactionIdFromEpochAndXid(EpochFromFullTransactionId(ControlFile.checkPointCopy.nextFullXid),
 											 set_xid);
 
+		/* ruins testing of cases close to wraparound */
+#if 0
 		/*
 		 * For the moment, just set oldestXid to a value that will force
 		 * immediate autovacuum-for-wraparound.  It's not clear whether adding
@@ -445,6 +447,7 @@ main(int argc, char *argv[])
 		if (ControlFile.checkPointCopy.oldestXid < FirstNormalTransactionId)
 			ControlFile.checkPointCopy.oldestXid += FirstNormalTransactionId;
 		ControlFile.checkPointCopy.oldestXidDB = InvalidOid;
+#endif
 	}
 
 	if (set_oldest_commit_ts_xid != 0)
diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh
index 7ff06de..befa5bb 100644
--- a/src/bin/pg_upgrade/test.sh
+++ b/src/bin/pg_upgrade/test.sh
@@ -28,6 +28,7 @@ standard_initdb() {
 	then
 		cat "$TEMP_CONFIG" >> "$PGDATA/postgresql.conf"
 	fi
+	echo "backtrace_functions = 'SlruReportIOError'" >> "$PGDATA/postgresql.conf"
 	../../test/regress/pg_regress --config-auth "$PGDATA"
 }
 
@@ -202,7 +203,39 @@ if "$MAKE" -C "$oldsrc" installcheck-parallel; then
 else
 	make_installcheck_status=$?
 fi
+
+# multixact alone between stop limit and wrap limit: no error
+reset_args_sql="
+select format('--multixact-ids=%s,%s',
+  oldest_multi_xid::text::bigint + (1::bigint << 31) - 50,
+  oldest_multi_xid)
+from pg_control_checkpoint();
+"
+# xid and multixact between warn limit and stop limit, noisy but successful:
+reset_args_sql="
+select format('--next-transaction-id=%s --multixact-ids=%s,%s',
+  oldest_xid::text::bigint       + (1::bigint << 31) - 5e6,
+  oldest_multi_xid::text::bigint + (1::bigint << 31) - 5e6,
+  oldest_multi_xid)
+from pg_control_checkpoint();
+"
+# xid and multixact between stop limit and wrap limit will fail:
+#   Setting frozenxid and minmxid counters in new cluster       SQL command failed
+#   UPDATE pg_catalog.pg_database SET       datfrozenxid = '2147484095'
+#   ERROR:  database is not accepting commands to avoid wraparound data loss in database "template0"
+reset_args_sql="
+select format('--next-transaction-id=%s --multixact-ids=%s,%s',
+  oldest_xid::text::bigint       + (1::bigint << 31) - 50,
+  oldest_multi_xid::text::bigint + (1::bigint << 31) - 50,
+  oldest_multi_xid)
+from pg_control_checkpoint();
+"
+reset_args=`psql -X -A -t -d template1 -c "$reset_args_sql"`
 "$oldbindir"/pg_ctl -m fast stop
+"$oldbindir"/pg_controldata | tee "$logdir"/before | grep 'Next.*X'
+"$oldbindir"/pg_resetwal $reset_args $PGDATA
+"$oldbindir"/pg_controldata | tee "$logdir"/after  | grep 'Next.*X'
+
 if [ -n "$createdb_status" ]; then
 	exit 1
 fi
