pgsql: Fix risk of deadlock failure while dropping a partitioned index.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix risk of deadlock failure while dropping a partitioned index.
Дата
Msg-id E1nWKnh-000jua-35@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix risk of deadlock failure while dropping a partitioned index.

DROP INDEX needs to lock the index's table before the index itself,
else it will deadlock against ordinary queries that acquire the
relation locks in that order.  This is correctly mechanized for
plain indexes by RangeVarCallbackForDropRelation; but in the case of
a partitioned index, we neglected to lock the child tables in advance
of locking the child indexes.  We can fix that by traversing the
inheritance tree and acquiring the needed locks in RemoveRelations,
after we have acquired our locks on the parent partitioned table and
index.

While at it, do some refactoring to eliminate confusion between
the actual and expected relkind in RangeVarCallbackForDropRelation.
We can save a couple of syscache lookups too, by having that function
pass back info that RemoveRelations will need.

Back-patch to v11 where partitioned indexes were added.

Jimmy Yih, Gaurab Dey, Tom Lane

Discussion: https://postgr.es/m/BYAPR05MB645402330042E17D91A70C12BD5F9@BYAPR05MB6454.namprd05.prod.outlook.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/05ccf974cd75d3a95869c4ce4b96fdbc10e663cf

Modified Files
--------------
src/backend/commands/tablecmds.c                   |  61 +++++++++----
.../expected/partition-drop-index-locking.out      | 100 +++++++++++++++++++++
src/test/isolation/isolation_schedule              |   1 +
.../specs/partition-drop-index-locking.spec        |  47 ++++++++++
4 files changed, 191 insertions(+), 18 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Remove workarounds for avoiding [U]INT64_FORMAT in translatable
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Move pg_attrdef manipulation code into new file catalog/pg_attrd