summaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorAmit Kapila2021-11-19 03:34:40 +0000
committerAmit Kapila2021-11-19 03:34:40 +0000
commit0f0cfb494004befb0f6e89d3129347869420c509 (patch)
tree575c00db6d52c852f556cda8415f7b6b157636fe /src/backend/access
parent0cd6d3b3c5aeac81903aa7de92e406f8567898a2 (diff)
Fix parallel operations that prevent oldest xmin from advancing.
While determining xid horizons, we skip over backends that are running Vacuum. We also ignore Create Index Concurrently, or Reindex Concurrently for the purposes of computing Xmin for Vacuum. But we were not setting the flags corresponding to these operations when they are performed in parallel which was preventing Xid horizon from advancing. The optimization related to skipping Create Index Concurrently, or Reindex Concurrently operations was implemented in PG-14 but the fix is the same for the Parallel Vacuum as well so back-patched till PG-13. Author: Masahiko Sawada Reviewed-by: Amit Kapila Backpatch-through: 13 Discussion: https://postgr.es/m/CAD21AoCLQqgM1sXh9BrDFq0uzd3RBFKi=Vfo6cjjKODm0Onr5w@mail.gmail.com
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/heap/vacuumlazy.c6
-rw-r--r--src/backend/access/nbtree/nbtsort.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 4ee1f148546..a00947ea1c6 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -4159,6 +4159,12 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc)
LVRelState vacrel;
ErrorContextCallback errcallback;
+ /*
+ * A parallel vacuum worker must have only PROC_IN_VACUUM flag since we
+ * don't support parallel vacuum for autovacuum as of now.
+ */
+ Assert(MyProc->statusFlags == PROC_IN_VACUUM);
+
lvshared = (LVShared *) shm_toc_lookup(toc, PARALLEL_VACUUM_KEY_SHARED,
false);
elevel = lvshared->elevel;
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 54c8eb1289d..1e02be9746b 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -1808,6 +1808,13 @@ _bt_parallel_build_main(dsm_segment *seg, shm_toc *toc)
ResetUsage();
#endif /* BTREE_BUILD_STATS */
+ /*
+ * The only possible status flag that can be set to the parallel worker is
+ * PROC_IN_SAFE_IC.
+ */
+ Assert((MyProc->statusFlags == 0) ||
+ (MyProc->statusFlags == PROC_IN_SAFE_IC));
+
/* Set debug_query_string for individual workers first */
sharedquery = shm_toc_lookup(toc, PARALLEL_KEY_QUERY_TEXT, true);
debug_query_string = sharedquery;