pgsql: Reorder steps in ConditionVariablePrepareToSleep for moresafety

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Reorder steps in ConditionVariablePrepareToSleep for moresafety
Дата
Msg-id E1eXcZd-0003uy-1W@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Reorder steps in ConditionVariablePrepareToSleep for more safety.

In the admittedly-very-unlikely case that AddWaitEventToSet fails,
ConditionVariablePrepareToSleep would error out after already having
set cv_sleep_target, which is probably bad, and after having already
set cv_wait_event_set, which is very bad.  Transaction abort might or
might not clean up cv_sleep_target properly; but there is nothing
that would be aware that the WaitEventSet wasn't fully constructed,
so that all future condition variable sleeps would be broken.
We can easily guard against these hazards with slight restructuring.

Back-patch to v10 where condition_variable.c was introduced.

Discussion: https://postgr.es/m/CAEepm=0NWKehYw7NDoUSf8juuKOPRnCyY3vuaSvhrEWsOTAa3w@mail.gmail.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/83fe2708d66889ed9ef6bdb922d27bba4b0d4f81

Modified Files
--------------
src/backend/storage/lmgr/condition_variable.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Rewrite ConditionVariableBroadcast() to avoid live-lock.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Remove return values of ConditionVariableSignal/Broadcast.