aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execParallel.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-14 15:18:10 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-14 15:18:10 +0200
commit84c18acaf690e438e953e387caf1c13298d4ecb4 (patch)
tree73fc82c43333153a4d5e39927c9c0b0d5ab9445a /src/backend/executor/execParallel.c
parent2346df6fc373df9c5ab944eebecf7d3036d727de (diff)
downloadpostgresql-84c18acaf690e438e953e387caf1c13298d4ecb4.tar.gz
postgresql-84c18acaf690e438e953e387caf1c13298d4ecb4.zip
Remove redundant snapshot copying from parallel leader to workers
The parallel query infrastructure copies the leader backend's active snapshot to the worker processes. But BitmapHeapScan node also had bespoken code to pass the snapshot from leader to the worker. That was redundant, so remove it. The removed code was analogous to the snapshot serialization in table_parallelscan_initialize(), but that was the wrong role model. A parallel bitmap heap scan is more like an independent non-parallel bitmap heap scan in each parallel worker as far as the table AM is concerned, because the coordination is done in nodeBitmapHeapscan.c, and the table AM doesn't need to know anything about it. This relies on the assumption that es_snapshot == GetActiveSnapshot(). That's not a new assumption, things would get weird if you used the QueryDesc's snapshot for visibility checks in the scans, but the active snapshot for evaluating quals, for example. This could use some refactoring and cleanup, but for now, just add some assertions. Reviewed-by: Dilip Kumar, Robert Haas Discussion: https://www.postgresql.org/message-id/5f3b9d59-0f43-419d-80ca-6d04c07cf61a@iki.fi
Diffstat (limited to 'src/backend/executor/execParallel.c')
-rw-r--r--src/backend/executor/execParallel.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index 3f84c002dc1..8c53d1834e9 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -720,6 +720,13 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
shm_toc_estimate_chunk(&pcxt->estimator, dsa_minsize);
shm_toc_estimate_keys(&pcxt->estimator, 1);
+ /*
+ * InitializeParallelDSM() passes the active snapshot to the parallel
+ * worker, which uses it to set es_snapshot. Make sure we don't set
+ * es_snapshot differently in the child.
+ */
+ Assert(GetActiveSnapshot() == estate->es_snapshot);
+
/* Everyone's had a chance to ask for space, so now create the DSM. */
InitializeParallelDSM(pcxt);