pgsql: Remove redundant snapshot copying from parallel leader to worker

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove redundant snapshot copying from parallel leader to worker
Date: 2024-03-14 13:32:00
Message-ID: E1rklBg-003ldt-K7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/84c18acaf690e438e953e387caf1c13298d4ecb4

Modified Files
--------------
src/backend/access/table/tableam.c | 10 ----------
src/backend/executor/execMain.c | 6 ++++++
src/backend/executor/execParallel.c | 7 +++++++
src/backend/executor/nodeBitmapHeapscan.c | 17 ++---------------
src/include/access/tableam.h | 5 -----
src/include/nodes/execnodes.h | 4 ----
6 files changed, 15 insertions(+), 34 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2024-03-14 16:05:44 pgsql: Add pg_column_toast_chunk_id().
Previous Message Robert Haas 2024-03-14 13:15:28 pgsql: Allow a no-wait lock acquisition to succeed in more cases.