@@ -367,9 +367,6 @@ static inline void ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId l
367367static void ProcArrayGroupClearXid (PGPROC * proc , TransactionId latestXid );
368368static void MaintainLatestCompletedXid (TransactionId latestXid );
369369static void MaintainLatestCompletedXidRecovery (TransactionId latestXid );
370- static void TransactionIdRetreatSafely (TransactionId * xid ,
371- int retreat_by ,
372- FullTransactionId rel );
373370
374371static inline FullTransactionId FullXidRelativeTo (FullTransactionId rel ,
375372 TransactionId xid );
@@ -1709,10 +1706,7 @@ TransactionIdIsActive(TransactionId xid)
17091706 * do about that --- data is only protected if the walsender runs continuously
17101707 * while queries are executed on the standby. (The Hot Standby code deals
17111708 * with such cases by failing standby queries that needed to access
1712- * already-removed data, so there's no integrity bug.) The computed values
1713- * are also adjusted with vacuum_defer_cleanup_age, so increasing that setting
1714- * on the fly is another easy way to make horizons move backwards, with no
1715- * consequences for data integrity.
1709+ * already-removed data, so there's no integrity bug.)
17161710 *
17171711 * Note: the approximate horizons (see definition of GlobalVisState) are
17181712 * updated by the computations done here. That's currently required for
@@ -1877,50 +1871,11 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
18771871 TransactionIdOlder (h -> data_oldest_nonremovable , kaxmin );
18781872 /* temp relations cannot be accessed in recovery */
18791873 }
1880- else
1881- {
1882- /*
1883- * Compute the cutoff XID by subtracting vacuum_defer_cleanup_age.
1884- *
1885- * vacuum_defer_cleanup_age provides some additional "slop" for the
1886- * benefit of hot standby queries on standby servers. This is quick
1887- * and dirty, and perhaps not all that useful unless the primary has a
1888- * predictable transaction rate, but it offers some protection when
1889- * there's no walsender connection. Note that we are assuming
1890- * vacuum_defer_cleanup_age isn't large enough to cause wraparound ---
1891- * so guc.c should limit it to no more than the xidStopLimit threshold
1892- * in varsup.c. Also note that we intentionally don't apply
1893- * vacuum_defer_cleanup_age on standby servers.
1894- *
1895- * Need to use TransactionIdRetreatSafely() instead of open-coding the
1896- * subtraction, to prevent creating an xid before
1897- * FirstNormalTransactionId.
1898- */
1899- Assert (TransactionIdPrecedesOrEquals (h -> oldest_considered_running ,
1900- h -> shared_oldest_nonremovable ));
1901- Assert (TransactionIdPrecedesOrEquals (h -> shared_oldest_nonremovable ,
1902- h -> data_oldest_nonremovable ));
19031874
1904- if (vacuum_defer_cleanup_age > 0 )
1905- {
1906- TransactionIdRetreatSafely (& h -> oldest_considered_running ,
1907- vacuum_defer_cleanup_age ,
1908- h -> latest_completed );
1909- TransactionIdRetreatSafely (& h -> shared_oldest_nonremovable ,
1910- vacuum_defer_cleanup_age ,
1911- h -> latest_completed );
1912- TransactionIdRetreatSafely (& h -> data_oldest_nonremovable ,
1913- vacuum_defer_cleanup_age ,
1914- h -> latest_completed );
1915- /* defer doesn't apply to temp relations */
1916-
1917-
1918- Assert (TransactionIdPrecedesOrEquals (h -> oldest_considered_running ,
1919- h -> shared_oldest_nonremovable ));
1920- Assert (TransactionIdPrecedesOrEquals (h -> shared_oldest_nonremovable ,
1921- h -> data_oldest_nonremovable ));
1922- }
1923- }
1875+ Assert (TransactionIdPrecedesOrEquals (h -> oldest_considered_running ,
1876+ h -> shared_oldest_nonremovable ));
1877+ Assert (TransactionIdPrecedesOrEquals (h -> shared_oldest_nonremovable ,
1878+ h -> data_oldest_nonremovable ));
19241879
19251880 /*
19261881 * Check whether there are replication slots requiring an older xmin.
@@ -1947,8 +1902,8 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
19471902 h -> slot_catalog_xmin );
19481903
19491904 /*
1950- * It's possible that slots / vacuum_defer_cleanup_age backed up the
1951- * horizons further than oldest_considered_running. Fix.
1905+ * It's possible that slots backed up the horizons further than
1906+ * oldest_considered_running. Fix.
19521907 */
19531908 h -> oldest_considered_running =
19541909 TransactionIdOlder (h -> oldest_considered_running ,
@@ -2490,15 +2445,9 @@ GetSnapshotData(Snapshot snapshot)
24902445 */
24912446 oldestfxid = FullXidRelativeTo (latest_completed , oldestxid );
24922447
2493- /* apply vacuum_defer_cleanup_age */
2494- def_vis_xid_data = xmin ;
2495- TransactionIdRetreatSafely (& def_vis_xid_data ,
2496- vacuum_defer_cleanup_age ,
2497- oldestfxid );
2498-
24992448 /* Check whether there's a replication slot requiring an older xmin. */
25002449 def_vis_xid_data =
2501- TransactionIdOlder (def_vis_xid_data , replication_slot_xmin );
2450+ TransactionIdOlder (xmin , replication_slot_xmin );
25022451
25032452 /*
25042453 * Rows in non-shared, non-catalog tables possibly could be vacuumed
@@ -4320,44 +4269,6 @@ GlobalVisCheckRemovableXid(Relation rel, TransactionId xid)
43204269 return GlobalVisTestIsRemovableXid (state , xid );
43214270}
43224271
4323- /*
4324- * Safely retract *xid by retreat_by, store the result in *xid.
4325- *
4326- * Need to be careful to prevent *xid from retreating below
4327- * FirstNormalTransactionId during epoch 0. This is important to prevent
4328- * generating xids that cannot be converted to a FullTransactionId without
4329- * wrapping around.
4330- *
4331- * If retreat_by would lead to a too old xid, FirstNormalTransactionId is
4332- * returned instead.
4333- */
4334- static void
4335- TransactionIdRetreatSafely (TransactionId * xid , int retreat_by , FullTransactionId rel )
4336- {
4337- TransactionId original_xid = * xid ;
4338- FullTransactionId fxid ;
4339- uint64 fxid_i ;
4340-
4341- Assert (TransactionIdIsNormal (original_xid ));
4342- Assert (retreat_by >= 0 ); /* relevant GUCs are stored as ints */
4343- AssertTransactionIdInAllowableRange (original_xid );
4344-
4345- if (retreat_by == 0 )
4346- return ;
4347-
4348- fxid = FullXidRelativeTo (rel , original_xid );
4349- fxid_i = U64FromFullTransactionId (fxid );
4350-
4351- if ((fxid_i - FirstNormalTransactionId ) <= retreat_by )
4352- * xid = FirstNormalTransactionId ;
4353- else
4354- {
4355- * xid = TransactionIdRetreatedBy (original_xid , retreat_by );
4356- Assert (TransactionIdIsNormal (* xid ));
4357- Assert (NormalTransactionIdPrecedes (* xid , original_xid ));
4358- }
4359- }
4360-
43614272/*
43624273 * Convert a 32 bit transaction id into 64 bit transaction id, by assuming it
43634274 * is within MaxTransactionId / 2 of XidFromFullTransactionId(rel).
0 commit comments