patch: fix race in SSI's CheckTargetForConflictsIn

Поиск
Список
Период
Сортировка
От Dan Ports
Тема patch: fix race in SSI's CheckTargetForConflictsIn
Дата
Msg-id 20110505014057.GR85173@csail.mit.edu
обсуждение исходный текст
Ответы Re: patch: fix race in SSI's CheckTargetForConflictsIn
Список pgsql-hackers
While running some benchmarks to test SSI performance, I found a race
condition that's capable of causing a segfault. A patch is attached.

The bug is in CheckTargetForConflictsIn, which scans the list of SIREAD
locks on a lock target when it's modified. There's an optimization in
there where the writing transaction will remove a SIREAD lock that it
holds itself, because it's being replaced with a (stronger) write lock.
To do that, it needs to drop its shared lwlocks and reacquire them in
exclusive mode. The existing code deals with concurrent modifications
in that interval by redoing checks. However, it misses the case where
some other transaction removes all remaining locks on the target, and
proceeds to remove the lock target itself.

The attached patch fixes this by deferring the SIREAD lock removal
until the end of the function. At that point, there isn't any need to
worry about concurrent updates to the target's lock list. The resulting
code is also simpler.

Dan

--
Dan R. K. Ports              MIT CSAIL                http://drkp.net/

Вложения

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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: Some surprising precedence behavior in PG's grammar
Следующее
От: Tatsuo Ishii
Дата:
Сообщение: Enhancing online recovery in SR mode