+ TransactionId OldestXmin;
+
+ /*
+ * We can't write WAL in recovery mode, so there's no point trying to
+ * clean the page. The master will likely issue a cleaning WAL record soon
+ * anyway, so this is no particular loss.
+ */
+ if (RecoveryInProgress())
+ return;
+
+ /*
+ * Use the appropriate xmin horizon for this relation. If it's a proper
+ * catalog relation or a user defined, additional, catalog relation, we
+ * need to use the horizon that includes slots, otherwise the data-only
+ * horizon can be used. Note that the toast relation of user defined
+ * relations are *not* considered catalog relations.
+ */
+ if (IsCatalogRelation(relation) ||
+ RelationIsAccessibleInLogicalDecoding(relation))
+ OldestXmin = RecentGlobalXmin;
+ else
+ OldestXmin = RecentGlobalDataXmin;
+
+ Assert(TransactionIdIsValid(OldestXmin));