aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execMain.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/execMain.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/execMain.c')
-rw-r--r--src/backend/executor/execMain.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 940499cc61a..7eb1f7d0209 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -147,6 +147,9 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags)
Assert(queryDesc != NULL);
Assert(queryDesc->estate == NULL);
+ /* caller must ensure the query's snapshot is active */
+ Assert(GetActiveSnapshot() == queryDesc->snapshot);
+
/*
* If the transaction is read-only, we need to check if any writes are
* planned to non-temporary tables. EXPLAIN is considered read-only.
@@ -319,6 +322,9 @@ standard_ExecutorRun(QueryDesc *queryDesc,
Assert(estate != NULL);
Assert(!(estate->es_top_eflags & EXEC_FLAG_EXPLAIN_ONLY));
+ /* caller must ensure the query's snapshot is active */
+ Assert(GetActiveSnapshot() == estate->es_snapshot);
+
/*
* Switch into per-query memory context
*/