Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a1e1d8

Browse files
committed
Use correct horizon when vacuuming catalog relations.
In dc7420c I (Andres) accidentally used RelationIsAccessibleInLogicalDecoding() as the sole condition to use the non-shared catalog horizon in GetOldestNonRemovableTransactionId(). That is incorrect, as RelationIsAccessibleInLogicalDecoding() checks whether wal_level is logical. The correct check, as done e.g. in GlobalVisTestFor(), is to check IsCatalogRelation() and RelationIsAccessibleInLogicalDecoding(). The observed misbehavior of this bug was that there could be an endless loop in lazy_scan_prune(), because the horizons used in heap_page_prune() and the individual tuple liveliness checks did not match. Likely there are other potential consequences as well. A later commit will unify the determination which horizon has to be used, and add additional assertions to make it easier to catch a bug like this. Reported-By: Justin Pryzby <pryzby@telsasoft.com> Diagnosed-By: Matthias van de Meent <boekewurm+postgres@gmail.com> Author: Matthias van de Meent <boekewurm+postgres@gmail.com> Discussion: https://postgr.es/m/CAEze2Wg32Y9+WJfw=aofkRx1ZRFt_Ev6bNPc4PSaz7PjSFtZgQ@mail.gmail.com
1 parent 8d29d45 commit 5a1e1d8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/storage/ipc/procarray.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1971,9 +1971,10 @@ GetOldestNonRemovableTransactionId(Relation rel)
19711971
ComputeXidHorizons(&horizons);
19721972

19731973
/* select horizon appropriate for relation */
1974-
if (rel == NULL || rel->rd_rel->relisshared)
1974+
if (rel == NULL || rel->rd_rel->relisshared || RecoveryInProgress())
19751975
return horizons.shared_oldest_nonremovable;
1976-
else if (RelationIsAccessibleInLogicalDecoding(rel))
1976+
else if (IsCatalogRelation(rel) ||
1977+
RelationIsAccessibleInLogicalDecoding(rel))
19771978
return horizons.catalog_oldest_nonremovable;
19781979
else if (RELATION_IS_LOCAL(rel))
19791980
return horizons.temp_oldest_nonremovable;

0 commit comments

Comments
 (0)