pgsql: Fix possibility of self-deadlock in ResolveRecoveryConflictWithB

Поиск
Список
Период
Сортировка
От Andres Freund
Тема pgsql: Fix possibility of self-deadlock in ResolveRecoveryConflictWithB
Дата
Msg-id E1nlhXe-002Gea-As@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix possibility of self-deadlock in ResolveRecoveryConflictWithBufferPin().

The tests added in 9f8a050f68d failed nearly reliably on FreeBSD in CI, and
occasionally on the buildfarm. That turns out to be caused not by a bug in the
test, but by a longstanding bug in recovery conflict handling.

The standby timeout handler, used by ResolveRecoveryConflictWithBufferPin(),
executed SendRecoveryConflictWithBufferPin() inside a signal handler. A bad
idea, because the deadlock timeout handler (or a spurious latch set) could
have interrupted ProcWaitForSignal(). If unlucky that could cause a
self-deadlock on ProcArrayLock, if the deadlock check is in
SendRecoveryConflictWithBufferPin()->CancelDBBackends().

To fix, set a flag in StandbyTimeoutHandler(), and check the flag in
ResolveRecoveryConflictWithBufferPin().

Subsequently the recovery conflict tests will be backpatched.

Discussion: https://postgr.es/m/20220413002626.udl7lll7f3o7nre7@alap3.anarazel.de
Backpatch: 10-

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/57c5ad168be1ce9a5e91adb4c576996921cd8627

Modified Files
--------------
src/backend/storage/ipc/standby.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)


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

Предыдущее
От: Andres Freund
Дата:
Сообщение: pgsql: Backpatch addition of wait_for_log(), pump_until().
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Fix incorrect format placeholders