postgresql/src
Amit Kapila 3d144c6c86 Fix invalid memory access during the shutdown of the parallel apply worker.
The callback function pa_shutdown() accesses MyLogicalRepWorker which may
not be initialized if there is an error during the initialization of the
parallel apply worker. The other problem is that by the time it is invoked
even after the initialization of the worker, the MyLogicalRepWorker will
be reset by another callback logicalrep_worker_onexit. So, it won't have
the required information.

To fix this, register the shutdown callback after we are attached to the
worker slot.

After this fix, we observed another issue which is that sometimes the
leader apply worker tries to receive the message from the error queue that
might already be detached by the parallel apply worker leading to an
error. To prevent such an error, we ensure that the leader apply worker
detaches from the parallel apply worker's error queue before stopping it.

Reported-by: Sawada Masahiko
Author: Hou Zhijie
Reviewed-by: Sawada Masahiko, Amit Kapila
Discussion: https://postgr.es/m/CAD21AoDo+yUwNq6nTrvE2h9bB2vZfcag=jxWc7QxuWCmkDAqcA@mail.gmail.com
2023-05-09 09:28:06 +05:30
..
backend Fix invalid memory access during the shutdown of the parallel apply worker. 2023-05-09 09:28:06 +05:30
bin Revert "ICU: do not convert locale 'C' to 'en-US-u-va-posix'." 2023-05-08 20:50:51 -07:00
common Introduce PG_IO_ALIGN_SIZE and align all I/O buffers. 2023-04-08 16:34:50 +12:00
fe_utils Revert refactoring of restore command code to shell_restore.c 2023-02-06 08:28:42 +09:00
include Fix invalid memory access during the shutdown of the parallel apply worker. 2023-05-09 09:28:06 +05:30
interfaces Fix typos in comments 2023-05-02 12:23:08 +09:00
makefiles Use --strip-unneeded when stripping static libraries with GNU strip. 2023-04-20 18:12:32 -04:00
pl Move return statements out of PG_TRY blocks. 2023-05-04 16:23:05 -07:00
port Fix various typos 2023-04-18 13:23:23 +12:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Revert "ICU: do not convert locale 'C' to 'en-US-u-va-posix'." 2023-05-08 20:50:51 -07:00
timezone Update time zone data files to tzdata release 2023c. 2023-04-18 14:46:39 -04:00
tools Doc: update pgindent/README some more. 2023-04-22 11:52:46 -04:00
tutorial Remove useless casts to (void *) in arguments of some system functions 2023-02-07 06:57:59 +01:00
.gitignore
DEVELOPERS
Makefile Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
Makefile.global.in Fix prove_installcheck when used with PGXS 2023-05-05 07:09:52 +02:00
Makefile.shlib autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
meson.build Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00