pgsql: Avoid getting more than AccessShareLock when deparsing a query.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Avoid getting more than AccessShareLock when deparsing a query.
Дата
Msg-id E1WLihc-0007BT-OP@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Avoid getting more than AccessShareLock when deparsing a query.

In make_ruledef and get_query_def, we have long used AcquireRewriteLocks
to ensure that the querytree we are about to deparse is up-to-date and
the schemas of the underlying relations aren't changing.  Howwever, that
function thinks the query is about to be executed, so it acquires locks
that are stronger than necessary for the purpose of deparsing.  Thus for
example, if pg_dump asks to deparse a rule that includes "INSERT INTO t",
we'd acquire RowExclusiveLock on t.  That results in interference with
concurrent transactions that might for example ask for ShareLock on t.
Since pg_dump is documented as being purely read-only, this is unexpected.
(Worse, it used to actually be read-only; this behavior dates back only
to 8.1, cf commit ba4200246.)

Fix this by adding a parameter to AcquireRewriteLocks to tell it whether
we want the "real" execution locks or only AccessShareLock.

Report, diagnosis, and patch by Dean Rasheed.  Back-patch to all supported
branches.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/7c31874945120c0a263c5d0fe15ab362e6e5c99d

Modified Files
--------------
src/backend/commands/matview.c       |    2 +-
src/backend/rewrite/rewriteHandler.c |   68 ++++++++++++++++++++++++----------
src/backend/utils/adt/ruleutils.c    |    7 +++-
src/include/rewrite/rewriteHandler.h |    4 +-
4 files changed, 57 insertions(+), 24 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Send keepalives from walsender even when busy sending WAL.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Avoid getting more than AccessShareLock when deparsing a query.