pgsql: Prevent deadlock in ginRedoDeletePage()

Поиск
Список
Период
Сортировка
От Alexander Korotkov
Тема pgsql: Prevent deadlock in ginRedoDeletePage()
Дата
Msg-id E1gXI6u-0005TY-8R@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Prevent deadlock in ginRedoDeletePage()

On standby ginRedoDeletePage() can work concurrently with read-only queries.
Those queries can traverse posting tree in two ways.
1) Using rightlinks by ginStepRight(), which locks the next page before
   unlocking its left sibling.
2) Using downlinks by ginFindLeafPage(), which locks at most one page at time.

Original lock order was: page, parent, left sibling.  That lock order can
deadlock with ginStepRight().  In order to prevent deadlock this commit changes
lock order to: left sibling, page, parent.  Note, that position of parent in
locking order seems insignificant, because we only lock one page at time while
traversing downlinks.

Reported-by: Chen Huajun
Diagnosed-by: Chen Huajun, Peter Geoghegan, Andrey Borodin
Discussion: https://postgr.es/m/31a702a.14dd.166c1366ac1.Coremail.chjischj%40163.com
Author: Alexander Korotkov
Backpatch-through: 9.4

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/19cf52e6cc33b9e126775f28269ccccb6ddf7e30

Modified Files
--------------
src/backend/access/gin/ginxlog.c | 44 +++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 19 deletions(-)


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

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Prevent deadlock in ginRedoDeletePage()
Следующее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Fix deadlock in GIN vacuum introduced by 218f51584d5