postgresql/src/backend
Amit Kapila 6c6d6ba3ee Fix the Drop Database hang.
The drop database command waits for the logical replication sync worker to
accept ProcSignalBarrier and the worker's slot creation waits for the drop
database to finish which leads to a deadlock. This happens because the
tablesync worker holds interrupts while creating a slot.

We prevent cancel/die interrupts while creating a slot in the table sync
worker because it is possible that before the server finishes this
command, a concurrent drop subscription happens which would complete
without removing this slot and that leads to the slot existing until the
end of walsender. However, the slot will eventually get dropped at the
walsender exit time, so there is no danger of the dangling slot.

This patch reallows cancel/die interrupts while creating a slot and
modifies the test to wait for slots to become zero to prevent finding an
ephemeral slot.

The reported hang doesn't happen in PG14 as the drop database starts to
wait for ProcSignalBarrier with PG15 (commits 4eb2176318 and e2f65f4255)
but it is good to backpatch this till PG14 as it is not a good idea to
prevent interrupts during a network call that could block indefinitely.

Reported-by: Lakshmi Narayanan Sreethar
Diagnosed-by: Andres Freund
Author: Hou Zhijie
Reviewed-by: Vignesh C, Amit Kapila
Backpatch-through: 14, where it was introduced in commit 6b67d72b60
Discussion: https://postgr.es/m/CA+kvmZELXQ4ZD3U=XCXuG3KvFgkuPoN1QrEj8c-rMRodrLOnsg@mail.gmail.com
2023-01-24 09:25:36 +05:30
..
access Fix XLogPageRead() comment 2023-01-23 21:46:30 +01:00
backup Add BufFileRead variants with short read and EOF detection 2023-01-16 11:01:31 +01:00
bootstrap Update copyright for 2023 2023-01-02 15:00:37 -05:00
catalog Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. 2023-01-21 13:10:29 -05:00
commands Track logrep apply workers' last start times to avoid useless waits. 2023-01-22 14:08:46 -05:00
executor Remove redundant grouping and DISTINCT columns. 2023-01-18 12:37:57 -05:00
foreign Update copyright for 2023 2023-01-02 15:00:37 -05:00
jit Fix typos in comments, code and documentation 2023-01-03 16:26:14 +09:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq Support the same patterns for pg-user in pg_ident.conf as in pg_hba.conf 2023-01-20 11:21:55 +09:00
main Update copyright for 2023 2023-01-02 15:00:37 -05:00
nodes Move queryjumble.c code to src/backend/nodes/ 2023-01-21 11:48:37 +09:00
optimizer Allow parallel aggregate on string_agg and array_agg 2023-01-23 17:35:01 +13:00
parser Allow parallel aggregate on string_agg and array_agg 2023-01-23 17:35:01 +13:00
partitioning Update copyright for 2023 2023-01-02 15:00:37 -05:00
po Update copyright for 2023 2023-01-02 15:00:37 -05:00
port Update copyright for 2023 2023-01-02 15:00:37 -05:00
postmaster Reject CancelRequestPacket having unexpected length. 2023-01-21 06:08:00 -08:00
regex Update copyright for 2023 2023-01-02 15:00:37 -05:00
replication Fix the Drop Database hang. 2023-01-24 09:25:36 +05:30
rewrite Get rid of the "new" and "old" entries in a view's rangetable. 2023-01-18 13:23:57 -05:00
snowball Update copyright for 2023 2023-01-02 15:00:37 -05:00
statistics Update copyright for 2023 2023-01-02 15:00:37 -05:00
storage Track logrep apply workers' last start times to avoid useless waits. 2023-01-22 14:08:46 -05:00
tcop Use WaitEventSet API for postmaster's event loop. 2023-01-12 16:32:20 +13:00
tsearch Fix ts_headline() to handle ORs and phrase queries more honestly. 2023-01-19 16:21:44 -05:00
utils Add non-decimal integer support to type numeric. 2023-01-23 19:21:22 +00:00
.gitignore
Makefile Update copyright for 2023 2023-01-02 15:00:37 -05:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00