pgsql: Restrict the use of temporary namespace in two-phasetransaction
От | Michael Paquier |
---|---|
Тема | pgsql: Restrict the use of temporary namespace in two-phasetransaction |
Дата | |
Msg-id | E1gkHvw-00010f-3Z@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
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 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b15160bc716e62ba0b30dc0ce35ab6cb82773707 Modified Files -------------- doc/src/sgml/ref/prepare_transaction.sgml | 4 +- src/backend/access/transam/xact.c | 12 ++++ src/backend/catalog/namespace.c | 59 +++++++++++++----- src/backend/commands/dropcmds.c | 8 +++ src/backend/commands/extension.c | 7 +++ src/backend/commands/lockcmds.c | 10 +++ src/include/access/xact.h | 5 ++ .../test_extensions/expected/test_extensions.out | 33 ++++++++++ .../test_extensions/sql/test_extensions.sql | 29 +++++++++ src/test/regress/expected/temp.out | 71 ++++++++++++++++++++++ src/test/regress/sql/temp.sql | 56 +++++++++++++++++ 11 files changed, 277 insertions(+), 17 deletions(-)
В списке pgsql-committers по дате отправления: