pgsql: Fix serialization anomalies due to race conditions on INSERT.

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема pgsql: Fix serialization anomalies due to race conditions on INSERT.
Дата
Msg-id E1ZscAI-0001R5-4Z@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix serialization anomalies due to race conditions on INSERT.

On insert the CheckForSerializableConflictIn() test was performed
before the page(s) which were going to be modified had been locked
(with an exclusive buffer content lock).  If another process
acquired a relation SIReadLock on the heap and scanned to a page on
which an insert was going to occur before the page was so locked,
a rw-conflict would be missed, which could allow a serialization
anomaly to be missed.  The window between the check and the page
lock was small, so the bug was generally not noticed unless there
was high concurrency with multiple processes inserting into the
same table.

This was reported by Peter Bailis as bug #11732, by Sean Chittenden
as bug #13667, and by others.

The race condition was eliminated in heap_insert() by moving the
check down below the acquisition of the buffer lock, which had been
the very next statement.  Because of the loop locking and unlocking
multiple buffers in heap_multi_insert() a check was added after all
inserts were completed.  The check before the start of the inserts
was left because it might avoid a large amount of work to detect a
serialization anomaly before performing the all of the inserts and
the related WAL logging.

While investigating this bug, other SSI bugs which were even harder
to hit in practice were noticed and fixed, an unnecessary check
(covered by another check, so redundant) was removed from
heap_update(), and comments were improved.

Back-patch to all supported branches.

Kevin Grittner and Thomas Munro

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/18479293cbc531209dbdf68f94cd7f86b5290a80

Modified Files
--------------
src/backend/access/heap/heapam.c     |   91 ++++++++++++++++++++++++----------
src/backend/storage/lmgr/predicate.c |    9 ++--
2 files changed, 69 insertions(+), 31 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Implement lookbehind constraints in our regular-expression engin
Следующее
От: Kevin Grittner
Дата:
Сообщение: pgsql: Fix serialization anomalies due to race conditions on INSERT.