postgresql/src/include
Thomas Munro 3b8981b6e1 Fix race in Parallel Hash Join batch cleanup.
With very unlucky timing and parallel_leader_participation off, PHJ
could attempt to access per-batch state just as it was being freed.
There was code intended to prevent that by checking for a cleared
pointer, but it was buggy.

Fix, by introducing an extra barrier phase.  The new phase
PHJ_BUILD_RUNNING means that it's safe to access the per-batch state to
find a batch to help with, and PHJ_BUILD_DONE means that it is too late.
The last to detach will free the array of per-batch state as before, but
now it will also atomically advance the phase at the same time, so that
late attachers can avoid the hazard, without the data race.  This
mirrors the way per-batch hash tables are freed (see phases
PHJ_BATCH_PROBING and PHJ_BATCH_DONE).

Revealed by a one-off build farm failure, where BarrierAttach() failed a
sanity check assertion, because the memory had been clobbered by
dsa_free().

Back-patch to 11, where the code arrived.

Reported-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/20200929061142.GA29096%40paquier.xyz
2021-03-17 18:05:39 +13:00
..
access Consolidate nbtree VACUUM metapage routines. 2021-03-12 13:11:47 -08:00
bootstrap Update copyright for 2021 2021-01-02 13:06:25 -05:00
catalog Improve FK trigger parallel-safety check added by 05c8482f7f. 2021-03-13 09:20:52 +05:30
commands Add support for more progress reporting in COPY 2021-03-09 14:21:03 +09:00
common Improve reporting for syntax errors in multi-line JSON data. 2021-03-01 16:44:17 -05:00
datatype Update copyright for 2021 2021-01-02 13:06:25 -05:00
executor Fix race in Parallel Hash Join batch cleanup. 2021-03-17 18:05:39 +13:00
fe_utils Refactor and generalize the ParallelSlot machinery. 2021-03-11 13:17:46 -05:00
foreign Implement support for bulk inserts in postgres_fdw 2021-01-20 23:57:27 +01:00
jit Update copyright for 2021 2021-01-02 13:06:25 -05:00
lib Add sort_template.h for making sort functions. 2021-03-03 17:02:22 +13:00
libpq Remove support for SSL compression 2021-03-09 11:16:47 +09:00
mb Add mbverifystr() functions specific to each encoding. 2021-01-28 14:40:07 +02:00
nodes Enable parallel SELECT for "INSERT INTO ... SELECT ...". 2021-03-10 07:38:58 +05:30
optimizer Enable parallel SELECT for "INSERT INTO ... SELECT ...". 2021-03-10 07:38:58 +05:30
parser Remove no-longer-used RTE argument of markVarForSelectPriv(). 2021-02-11 11:23:25 -05:00
partitioning Remove [Merge]AppendPath.partitioned_rels. 2021-02-01 14:43:54 -05:00
port Add missing pthread_barrier_t. 2021-03-10 17:44:04 +13:00
portability Fix another portability bug in recent pgbench commit. 2021-03-10 23:20:41 +13:00
postmaster Make archiver process an auxiliary process. 2021-03-15 13:13:14 +09:00
regex Improve memory management in regex compiler. 2021-02-26 13:52:10 -05:00
replication Add condition variable for walreceiver shutdown. 2021-03-12 19:45:42 +13:00
rewrite SEARCH and CYCLE clauses 2021-02-01 14:32:51 +01:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Update copyright for 2021 2021-01-02 13:06:25 -05:00
storage Make archiver process an auxiliary process. 2021-03-15 13:13:14 +09:00
tcop Remove server and libpq support for old FE/BE protocol version 2. 2021-03-04 10:45:55 +02:00
tsearch Convert tsginidx.c's GIN indexing logic to fully ternary operation. 2021-02-16 12:07:14 -05:00
utils Remove server and libpq support for old FE/BE protocol version 2. 2021-03-04 10:45:55 +02:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Work around issues in MinGW-64's setjmp/longjmp support. 2021-03-15 12:34:17 -04:00
fmgr.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
funcapi.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
getaddrinfo.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
getopt_long.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
Makefile Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
miscadmin.h Make archiver process an auxiliary process. 2021-03-15 13:13:14 +09:00
pg_config.h.in Add missing pthread_barrier_t. 2021-03-10 17:44:04 +13:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix some typos, grammar and style in docs and comments 2021-02-24 16:13:17 +09:00
pg_getopt.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_trace.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pgstat.h Add condition variable for walreceiver shutdown. 2021-03-12 19:45:42 +13:00
pgtar.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pgtime.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
port.h pg_upgrade: Check version of target cluster binaries 2021-03-03 09:45:56 +01:00
postgres.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
rusagestub.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
windowapi.h Update copyright for 2021 2021-01-02 13:06:25 -05:00