Repurpose PROC_COPYABLE_FLAGS as PROC_XMIN_FLAGS
authorAlvaro Herrera
Thu, 19 May 2022 14:20:32 +0000 (16:20 +0200)
committerAlvaro Herrera
Thu, 19 May 2022 14:20:32 +0000 (16:20 +0200)
This is a slight, convenient semantics change from what commit
0f0cfb494004 ("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 6fea65508a1a ("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
Discussion: https://postgr.es/m/202204191637[email protected]

src/backend/storage/ipc/procarray.c
src/include/storage/proc.h

index 6ff8d8699b3d005e979f263d4be6a7488edfedb2..447b6e3de7f0eeb6ed2a8380116b9344555746e2 100644 (file)
@@ -1916,12 +1916,13 @@ ProcArrayInstallRestoredXmin(TransactionId xmin, PGPROC *proc)
        TransactionIdIsNormal(xid) &&
        TransactionIdPrecedesOrEquals(xid, xmin))
    {
-       /* Install xmin */
+       /*
+        * Install xmin and propagate the vacuumFlags that affect how the
+        * value is interpreted by vacuum.
+        */
        MyPgXact->xmin = TransactionXmin = xmin;
-
-       /* Flags being copied must be valid copy-able flags. */
-       Assert((pgxact->vacuumFlags & (~PROC_COPYABLE_FLAGS)) == 0);
-       MyPgXact->vacuumFlags = pgxact->vacuumFlags;
+       MyPgXact->vacuumFlags = (MyPgXact->vacuumFlags & ~PROC_XMIN_FLAGS) |
+           (pgxact->vacuumFlags & PROC_XMIN_FLAGS);
 
        result = true;
    }
index 9cf9684b41ccc75c9c3d225a711ed80032c74d6a..7c85b5645b76d8b5e88736b5e926ca7233c80b90 100644 (file)
@@ -63,11 +63,10 @@ struct XidCache
    (PROC_IN_VACUUM | PROC_IN_ANALYZE | PROC_VACUUM_FOR_WRAPAROUND)
 
 /*
- * Flags that are valid to copy from another proc, the parallel leader
- * process in practice.  Currently, a flag that is set during parallel
- * vacuum is allowed.
+ * Xmin-related flags. Make sure any flags that affect how the process' Xmin
+ * value is interpreted by VACUUM are included here.
  */
-#define        PROC_COPYABLE_FLAGS (PROC_IN_VACUUM)
+#define        PROC_XMIN_FLAGS (PROC_IN_VACUUM)
 
 /*
  * We allow a small number of "weak" relation locks (AccessShareLock,