Skip to content

Commit 8d061ac

Browse files
committed
Repurpose PROC_COPYABLE_FLAGS as PROC_XMIN_FLAGS
This is a slight, convenient semantics change from what commit 0f0cfb4 ("Fix parallel operations that prevent oldest xmin from advancing") introduced that lets us simplify the coding in the one place where it is used. Backpatch to 13. This is related to commit 6fea655 ("Tighten ComputeXidHorizons' handling of walsenders") rewriting the code site where this is used, which has not yet been backpatched, but it may well be in the future. Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Discussion: https://postgr.es/m/202204191637.eldwa2exvguw@alvherre.pgsql
1 parent a1e7616 commit 8d061ac

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,17 +2685,14 @@ ProcArrayInstallRestoredXmin(TransactionId xmin, PGPROC *proc)
26852685
TransactionIdIsNormal(xid) &&
26862686
TransactionIdPrecedesOrEquals(xid, xmin))
26872687
{
2688-
/* Install xmin */
2688+
/*
2689+
* Install xmin and propagate the statusFlags that affect how the
2690+
* value is interpreted by vacuum.
2691+
*/
26892692
MyProc->xmin = TransactionXmin = xmin;
2690-
2691-
/* walsender cheats by passing proc == MyProc, don't check its flags */
2692-
if (proc != MyProc)
2693-
{
2694-
/* Flags being copied must be valid copy-able flags. */
2695-
Assert((proc->statusFlags & (~PROC_COPYABLE_FLAGS)) == 0);
2696-
MyProc->statusFlags = proc->statusFlags;
2697-
ProcGlobal->statusFlags[MyProc->pgxactoff] = MyProc->statusFlags;
2698-
}
2693+
MyProc->statusFlags = (MyProc->statusFlags & ~PROC_XMIN_FLAGS) |
2694+
(proc->statusFlags & PROC_XMIN_FLAGS);
2695+
ProcGlobal->statusFlags[MyProc->pgxactoff] = MyProc->statusFlags;
26992696

27002697
result = true;
27012698
}

src/include/storage/proc.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ struct XidCache
6969
(PROC_IN_VACUUM | PROC_IN_SAFE_IC | PROC_VACUUM_FOR_WRAPAROUND)
7070

7171
/*
72-
* Flags that are valid to copy from another proc, the parallel leader
73-
* process in practice. Currently, flags that are set during parallel
74-
* vacuum and parallel index creation are allowed.
72+
* Xmin-related flags. Make sure any flags that affect how the process' Xmin
73+
* value is interpreted by VACUUM are included here.
7574
*/
76-
#define PROC_COPYABLE_FLAGS (PROC_IN_VACUUM | PROC_IN_SAFE_IC)
75+
#define PROC_XMIN_FLAGS (PROC_IN_VACUUM | PROC_IN_SAFE_IC)
7776

7877
/*
7978
* We allow a small number of "weak" relation locks (AccessShareLock,

0 commit comments

Comments
 (0)