postgresql/src
Michael Paquier b15160bc71 Restrict the use of temporary namespace in two-phase transactions
Attempting to use a temporary table within a two-phase transaction is
forbidden for ages.  However, there have been uncovered grounds for
a couple of other object types and commands which work on temporary
objects with two-phase commit.  In short, trying to create, lock or drop
an object on a temporary schema should not be authorized within a
two-phase transaction, as it would cause its state to create
dependencies with other sessions, causing all sorts of side effects with
the existing session or other sessions spawned later on trying to use
the same temporary schema name.

Regression tests are added to cover all the grounds found, the original
report mentioned function creation, but monitoring closer there are many
other patterns with LOCK, DROP or CREATE EXTENSION which are involved.
One of the symptoms resulting in combining both is that the session
which used the temporary schema is not able to shut down completely,
waiting for being able to drop the temporary schema, something that it
cannot complete because of the two-phase transaction involved with
temporary objects.  In this case the client is able to disconnect but
the session remains alive on the backend-side, potentially blocking
connection backend slots from being used.  Other problems reported could
also involve server crashes.

This is back-patched down to v10, which is where 9b013dc has introduced
MyXactFlags, something that this patch relies on.

Reported-by: Alexey Bashtanov
Author: Michael Paquier
Reviewed-by: Masahiko Sawada
Discussion: https://postgr.es/m/5d910e2e-0db8-ec06-dd5f-baec420513c3@imap.cc
Backpatch-through: 10
2019-01-18 09:21:58 +09:00
..
backend Restrict the use of temporary namespace in two-phase transactions 2019-01-18 09:21:58 +09:00
bin pg_rewind: Add missing newline to error message 2018-12-29 13:03:22 +01:00
common Fix portability failure introduced in commits d2b0b60e7 et al. 2018-12-26 15:30:27 -05:00
fe_utils Fix translation of special characters in psql's LaTeX output modes. 2018-11-26 17:32:51 -05:00
include Restrict the use of temporary namespace in two-phase transactions 2019-01-18 09:21:58 +09:00
interfaces Second try at fixing numeric data passed through an ECPG SQLDA. 2018-11-14 11:27:30 -05:00
makefiles Fix up confusion over how to use EXTRA_INSTALL. 2019-01-11 17:39:30 -05:00
pl Translation updates 2018-11-05 14:46:40 +01:00
port Fix latent problem with pg_jrand48(). 2018-12-28 14:08:35 -05:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Restrict the use of temporary namespace in two-phase transactions 2019-01-18 09:21:58 +09:00
timezone Sync our copy of the timezone library with IANA release tzcode2018g. 2018-10-31 09:48:08 -04:00
tools Add valgrind suppressions for wcsrtombs optimizations 2018-11-18 00:08:48 +01:00
tutorial Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
.gitignore
DEVELOPERS
Makefile Build src/test/isolation during "make" and "make install". 2017-11-22 20:18:52 -08:00
Makefile.global.in fix typo 2019-01-13 16:44:05 -05:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00