postgresql/src/backend
Tom Lane 6310809c4a Fix check for conflicting session- vs transaction-level locks.
We have an implementation restriction that PREPARE TRANSACTION can't
handle cases where both session-lifespan and transaction-lifespan locks
are held on the same lockable object.  (That's because we'd otherwise
need to acquire a new PROCLOCK entry during post-prepare cleanup, which
is an operation that might fail.  The situation can only arise with odd
usages of advisory locks, so removing the restriction is probably not
worth the amount of effort it would take.)  AtPrepare_Locks attempted
to enforce this, but its logic was many bricks shy of a load, because
it only detected cases where the session and transaction locks had the
same lockmode.  Locks of different modes on the same object would lead
to the rather unhelpful message "PANIC: we seem to have dropped a bit
somewhere".

To fix, build a transient hashtable with one entry per locktag,
not one per locktag + mode, and use that to detect conflicts.

Per bug #17122 from Alexander Pyhalov.  This bug is ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17122-04f3c32098a62233@postgresql.org
2021-07-24 18:35:52 -04:00
..
access Make XLOG_FPI_FOR_HINT records honor full_page_writes setting. 2021-07-21 11:19:00 +09:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog More improvements of error messages about mismatching relkind 2021-07-21 07:52:10 +02:00
commands Make ALTER TRIGGER RENAME consistent for partitioned tables 2021-07-22 18:33:47 -04:00
executor Make nodeSort.c use Datum sorts for single column sorts 2021-07-22 14:03:19 +12:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit jit: Don't inline functions that access thread-locals. 2021-07-22 15:02:18 +12:00
lib Fix typo in comment 2021-04-20 14:35:16 +02:00
libpq Add more sanity checks in SASL exchanges 2021-07-10 21:45:28 +09:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Rename some node support functions for consistency 2021-07-21 10:24:06 +02:00
optimizer Use l*_node() family of functions where appropriate 2021-07-19 08:20:24 +02:00
parser Use l*_node() family of functions where appropriate 2021-07-19 08:20:24 +02:00
partitioning Use l*_node() family of functions where appropriate 2021-07-19 08:20:24 +02:00
po Translation updates 2021-06-21 12:33:50 +02:00
port Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
postmaster Remove unnecessary assertion in postmaster.c 2021-07-15 15:00:45 +09:00
regex Fix performance issue in new regex match-all detection code. 2021-05-03 11:42:31 -04:00
replication Fix potential buffer overruns in proto.c. 2021-07-20 08:15:01 +05:30
rewrite Use l*_node() family of functions where appropriate 2021-07-19 08:20:24 +02:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Error message refactoring 2021-06-27 09:41:16 +02:00
storage Fix check for conflicting session- vs transaction-level locks. 2021-07-24 18:35:52 -04:00
tcop Use l*_node() family of functions where appropriate 2021-07-19 08:20:24 +02:00
tsearch Improve various places that double the size of a buffer 2021-07-01 15:29:06 +12:00
utils Fix division by zero error in date_bin 2021-07-22 17:34:19 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-05-10 14:36:21 +02:00