pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix parallel BRIN builds with synchronized scans
Date: Sat, 30 Dec 2023 22:18:01 +0000
Message-ID: <E1rJhea-00Chmd-TM@gemulon.postgresql.org> (raw)

Fix parallel BRIN builds with synchronized scans

The brinbuildCallbackParallel callback used by parallel BRIN builds did
not consider that the parallel table scans may be synchronized, starting
from an arbitrary block and then wrap around.

If this happened and the scan actually did wrap around, tuples from the
beginning of the table were added to the last range produced by the same
worker. The index would be missing range at the beginning of the table,
while the last range would be too wide. This would not produce incorrect
query results, but it'd be less efficient.

Fixed by checking for both past and future ranges in the callback. The
worker may produce multiple summaries for the same page range, but the
leader will merge them as if the summaries came from different workers.

Discussion: https://postgr.es/m/c2ee7d69-ce17-43f2-d1a0-9811edbda6e6%40enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cb44a8345e7c248cf4158f2702fd9c9358399cfb

Modified Files
--------------
src/backend/access/brin/brin.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)



Message-ID: <E1rJhea-00Chmd-TM@gemulon.postgresql.org>
Permalink:  ../E1rJhea-00Chmd-TM@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rJhea-00Chmd-TM@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix parallel BRIN builds with synchronized scans
  In-Reply-To: <E1rJhea-00Chmd-TM@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox