From d7bad690ec67a5cec3e229cf5a282e83019cede8 Mon Sep 17 00:00:00 2001 From: Matthias van de Meent Date: Mon, 1 Nov 2021 15:51:30 +0100 Subject: [PATCH] Fix stuck vacuum due to retreating GlobalVisState->maybe_needed The issue is solved by guaranteeing that a backend's maybe_needed will never go backwards. --- src/backend/storage/ipc/procarray.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 9fcd12020a..374b7a2633 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -4087,17 +4087,25 @@ static void GlobalVisUpdateApply(ComputeXidHorizonsResult *horizons) { GlobalVisSharedRels.maybe_needed = - FullXidRelativeTo(horizons->latest_completed, - horizons->shared_oldest_nonremovable); + FullTransactionIdNewer( + GlobalVisSharedRels.maybe_needed, + FullXidRelativeTo(horizons->latest_completed, + horizons->shared_oldest_nonremovable)); GlobalVisCatalogRels.maybe_needed = - FullXidRelativeTo(horizons->latest_completed, - horizons->catalog_oldest_nonremovable); + FullTransactionIdNewer( + GlobalVisCatalogRels.maybe_needed, + FullXidRelativeTo(horizons->latest_completed, + horizons->catalog_oldest_nonremovable)); GlobalVisDataRels.maybe_needed = - FullXidRelativeTo(horizons->latest_completed, - horizons->data_oldest_nonremovable); + FullTransactionIdNewer( + GlobalVisDataRels.maybe_needed, + FullXidRelativeTo(horizons->latest_completed, + horizons->data_oldest_nonremovable)); GlobalVisTempRels.maybe_needed = - FullXidRelativeTo(horizons->latest_completed, - horizons->temp_oldest_nonremovable); + FullTransactionIdNewer( + GlobalVisTempRels.maybe_needed, + FullXidRelativeTo(horizons->latest_completed, + horizons->temp_oldest_nonremovable)); /* * In longer running transactions it's possible that transactions we -- 2.30.2