Skip to content

Commit 9d940e2

Browse files
akorotkovpashkinelfe
authored andcommitted
Use VacuumHorizonHook in more places
1 parent e24eb48 commit 9d940e2

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <signal.h>
4949

5050
#include "access/clog.h"
51+
#include "access/heapam.h"
5152
#include "access/subtrans.h"
5253
#include "access/transam.h"
5354
#include "access/twophase.h"
@@ -2004,23 +2005,36 @@ TransactionId
20042005
GetOldestNonRemovableTransactionId(Relation rel)
20052006
{
20062007
ComputeXidHorizonsResult horizons;
2008+
TransactionId result = InvalidTransactionId;
20072009

20082010
ComputeXidHorizons(&horizons);
20092011

20102012
switch (GlobalVisHorizonKindForRel(rel))
20112013
{
20122014
case VISHORIZON_SHARED:
2013-
return horizons.shared_oldest_nonremovable;
2015+
result = horizons.shared_oldest_nonremovable;
2016+
break;
20142017
case VISHORIZON_CATALOG:
2015-
return horizons.catalog_oldest_nonremovable;
2018+
result = horizons.catalog_oldest_nonremovable;
2019+
break;
20162020
case VISHORIZON_DATA:
2017-
return horizons.data_oldest_nonremovable;
2021+
result = horizons.data_oldest_nonremovable;
2022+
break;
20182023
case VISHORIZON_TEMP:
2019-
return horizons.temp_oldest_nonremovable;
2024+
result = horizons.temp_oldest_nonremovable;
2025+
break;
20202026
}
20212027

2022-
/* just to prevent compiler warnings */
2023-
return InvalidTransactionId;
2028+
if (VacuumHorizonHook)
2029+
{
2030+
TransactionId horizon = VacuumHorizonHook();
2031+
2032+
if (TransactionIdIsValid(horizon) &&
2033+
TransactionIdFollows(result, horizon))
2034+
result = horizon;
2035+
}
2036+
2037+
return result;
20242038
}
20252039

20262040
/*
@@ -4114,6 +4128,20 @@ GlobalVisTestFor(Relation rel)
41144128
break;
41154129
}
41164130

4131+
if (VacuumHorizonHook)
4132+
{
4133+
TransactionId horizon = VacuumHorizonHook();
4134+
if (TransactionIdIsValid(horizon))
4135+
{
4136+
FullTransactionId fullHorizon = FullXidRelativeTo(state->definitely_needed, horizon);
4137+
4138+
if (FullTransactionIdFollows(state->definitely_needed, fullHorizon))
4139+
state->definitely_needed = fullHorizon;
4140+
if (FullTransactionIdFollows(state->maybe_needed, fullHorizon))
4141+
state->maybe_needed = fullHorizon;
4142+
}
4143+
}
4144+
41174145
Assert(FullTransactionIdIsValid(state->definitely_needed) &&
41184146
FullTransactionIdIsValid(state->maybe_needed));
41194147

0 commit comments

Comments
 (0)