postgresql/src
Amit Kapila 6d0eb38557 Fix deadlock for multiple replicating truncates of the same table.
While applying the truncate change, the logical apply worker acquires
RowExclusiveLock on the relation being truncated. This allowed truncate on
the relation at a time by two apply workers which lead to a deadlock. The
reason was that one of the workers after updating the pg_class tuple tries
to acquire SHARE lock on the relation and started to wait for the second
worker which has acquired RowExclusiveLock on the relation. And when the
second worker tries to update the pg_class tuple, it starts to wait for
the first worker which leads to a deadlock. Fix it by acquiring
AccessExclusiveLock on the relation before applying the truncate change as
we do for normal truncate operation.

Author: Peter Smith, test case by Haiying Tang
Reviewed-by: Dilip Kumar, Amit Kapila
Backpatch-through: 11
Discussion: https://postgr.es/m/CAHut+PsNm43p0jM+idTvWwiGZPcP0hGrHMPK9TOAkc+a4UpUqw@mail.gmail.com
2021-05-21 07:54:27 +05:30
..
backend Fix deadlock for multiple replicating truncates of the same table. 2021-05-21 07:54:27 +05:30
bin Clean up cpluspluscheck violation. 2021-05-20 13:03:08 -04:00
common Factor out system call names from error messages 2021-04-23 14:21:37 +02:00
fe_utils psql: Fix line continuation prompts for unbalanced parentheses 2021-04-29 09:04:31 +02:00
include Fix issues in pg_stat_wal. 2021-05-19 11:38:34 +09:00
interfaces Translation updates 2021-05-17 14:30:27 +02:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Avoid detoasting failure after COMMIT inside a plpgsql FOR loop. 2021-05-20 18:32:37 -04:00
port Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:23 -05:00
test Fix deadlock for multiple replicating truncates of the same table. 2021-05-21 07:54:27 +05:30
timezone Update time zone data files to tzdata release 2021a. 2021-01-24 16:29:47 -05:00
tools Avoid creating testtablespace directories where not wanted. 2021-05-19 14:04:01 -04:00
tutorial doc: Prefer explicit JOIN syntax over old implicit syntax in tutorial 2021-04-08 10:51:26 +02:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Update Unicode data to CLDR 39 2021-04-08 08:28:03 +02:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk Add errhint_plural() function and make use of it 2021-03-31 09:16:25 +02:00