pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix serialization anomalies due to race conditions on INSERT.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix serialization anomalies due to race conditions on INSERT.
@ 2015-10-31 19:50  Kevin Grittner <kgrittn@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Kevin Grittner @ 2015-10-31 19:50 UTC (permalink / raw)
  To: 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(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix serialization anomalies due to race conditions on INSERT.
@ 2015-10-31 19:50  Kevin Grittner <kgrittn@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Kevin Grittner @ 2015-10-31 19:50 UTC (permalink / raw)
  To: 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
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/585e2a3b1a57cd7f763a9203e77563c729d6104e

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


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix serialization anomalies due to race conditions on INSERT.
@ 2015-10-31 19:50  Kevin Grittner <kgrittn@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Kevin Grittner @ 2015-10-31 19:50 UTC (permalink / raw)
  To: 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_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/50ca917d911485aa696a30943fda98f41ff92206

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


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix serialization anomalies due to race conditions on INSERT.
@ 2015-10-31 19:50  Kevin Grittner <kgrittn@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Kevin Grittner @ 2015-10-31 19:50 UTC (permalink / raw)
  To: 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_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/08322daed33e0c35b77194c4ad70dbd21790c7e6

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


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix serialization anomalies due to race conditions on INSERT.
@ 2015-10-31 19:50  Kevin Grittner <kgrittn@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Kevin Grittner @ 2015-10-31 19:50 UTC (permalink / raw)
  To: 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_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/1d95617f7039d77bba09415db6ca9b4bc8791cf6

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


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix serialization anomalies due to race conditions on INSERT.
@ 2015-10-31 19:50  Kevin Grittner <kgrittn@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Kevin Grittner @ 2015-10-31 19:50 UTC (permalink / raw)
  To: 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_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/caff7fc3fb1184d0fe39228cd8922e664006105b

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


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2015-10-31 19:50 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-10-31 19:50 pgsql: Fix serialization anomalies due to race conditions on INSERT. Kevin Grittner <kgrittn@postgresql.org>
2015-10-31 19:50 pgsql: Fix serialization anomalies due to race conditions on INSERT. Kevin Grittner <kgrittn@postgresql.org>
2015-10-31 19:50 pgsql: Fix serialization anomalies due to race conditions on INSERT. Kevin Grittner <kgrittn@postgresql.org>
2015-10-31 19:50 pgsql: Fix serialization anomalies due to race conditions on INSERT. Kevin Grittner <kgrittn@postgresql.org>
2015-10-31 19:50 pgsql: Fix serialization anomalies due to race conditions on INSERT. Kevin Grittner <kgrittn@postgresql.org>
2015-10-31 19:50 pgsql: Fix serialization anomalies due to race conditions on INSERT. Kevin Grittner <kgrittn@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox