Repository navigation
Conversation
_brin_parallel_scan_and_build() takes a "progress" argument, which the leader passes as true and parallel workers pass as false, but it ignored the argument and always asked table_index_build_scan() to report progress. Progress reporting is wasted effort on workers, since the scan writes it to the worker's own backend entry, which is not shown in pg_stat_progress_create_index and is not copied to the leader. Adjust to match how GIN and nbtree handle it, by passing the argument through to the underlying scan. Oversight in b437571, which added parallel index builds for BRIN. Author: Lukas Fittl <lukas@fittl.com> Reviewed-by: Discussion: https://postgr.es/m/CAP53Pkw3WcVbg61G29AmN=6XkuxGryoWKnhTyC1JmkT08i8qVA@mail.gmail.com
Multiple parallel mechanisms outside of the executor (nbtree/GIN/BRIN index builds, vacuum) all had the same implementation for passing query text to the parallel workers. To reduce duplicated code, introduce new helper functions to: (1) estimate the needed shared memory space for the query text, (2) store the query text in shared memory, and (3) restore the query text in the worker. Author: Lukas Fittl <lukas@fittl.com> Reviewed-by: Sami Imseih <samimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAP53Pkw3WcVbg61G29AmN=6XkuxGryoWKnhTyC1JmkT08i8qVA@mail.gmail.com
The three in-tree index AMs that currently support parallel index builds (nbtree, gin and brin) each share very similar code for initializing parallel workers, allocating shared memory and communicating between the leader and the workers. To reduce duplication, introduce shared helpers for parallel index builds, unifying the existing code. Author: Lukas Fittl <lukas@fittl.com> Reviewed-by: Sami Imseih <samimseih@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAP53Pkw3WcVbg61G29AmN=6XkuxGryoWKnhTyC1JmkT08i8qVA@mail.gmail.com
The parallel index build helpers left it to each AM to pass the ii_BrokenHotChain flag from the IndexInfo used for its heap scan into ParallelIndexBuildReportScanDone(), and to read it back out of ParallelIndexBuildWaitForWorkers() into the IndexInfo passed to ambuild. This is brittle and both GIN and BRIN have gotten this wrong in the past, and there are extensions that handled this wrong as well. Instead, introduce ParallelIndexBuildScan(), which builds the IndexInfo, joins the shared parallel scan, runs table_index_build_scan() and records a broken HOT chain itself. ParallelTableScanDescData is now stored in a separate shmem TOC entry for easier handling. Author: Lukas Fittl <lukas@fittl.com> Reviewed-by: Discussion: https://postgr.es/m/CAP53Pkw3WcVbg61G29AmN=6XkuxGryoWKnhTyC1JmkT08i8qVA@mail.gmail.com
lfittl
force-pushed
the
refactor-parallel-workers-v3
branch
from
November 26, 2026 19:28
6c366d5 to
a8f3f93
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.