pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Guard against spurious signals in LockBufferForCleanup.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Guard against spurious signals in LockBufferForCleanup.
@ 2015-02-23 15:25  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Andres Freund @ 2015-02-23 15:25 UTC (permalink / raw)
  To: pgsql-committers

Guard against spurious signals in LockBufferForCleanup.

When LockBufferForCleanup() has to wait for getting a cleanup lock on a
buffer it does so by setting a flag in the buffer header and then wait
for other backends to signal it using ProcWaitForSignal().
Unfortunately LockBufferForCleanup() missed that ProcWaitForSignal() can
return for other reasons than the signal it is hoping for. If such a
spurious signal arrives the wait flags on the buffer header will still
be set. That then triggers "ERROR: multiple backends attempting to wait
for pincount 1".

The fix is simple, unset the flag if still set when retrying. That
implies an additional spinlock acquisition/release, but that's unlikely
to matter given the cost of waiting for a cleanup lock.  Alternatively
it'd have been possible to move responsibility for maintaining the
relevant flag to the waiter all together, but that might have had
negative consequences due to possible floods of signals. Besides being
more invasive.

This looks to be a very longstanding bug. The relevant code in
LockBufferForCleanup() hasn't changed materially since its introduction
and ProcWaitForSignal() was documented to return for unrelated reasons
since 8.2.  The master only patch series removing ImmediateInterruptOK
made it much easier to hit though, as ProcSendSignal/ProcWaitForSignal
now uses a latch shared with other tasks.

Per discussion with Kevin Grittner, Tom Lane and me.

Backpatch to all supported branches.

Discussion: 11553.1423805224@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   14 ++++++++++++++
1 file changed, 14 insertions(+)


-- 
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: Guard against spurious signals in LockBufferForCleanup.
@ 2015-02-23 15:25  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Andres Freund @ 2015-02-23 15:25 UTC (permalink / raw)
  To: pgsql-committers

Guard against spurious signals in LockBufferForCleanup.

When LockBufferForCleanup() has to wait for getting a cleanup lock on a
buffer it does so by setting a flag in the buffer header and then wait
for other backends to signal it using ProcWaitForSignal().
Unfortunately LockBufferForCleanup() missed that ProcWaitForSignal() can
return for other reasons than the signal it is hoping for. If such a
spurious signal arrives the wait flags on the buffer header will still
be set. That then triggers "ERROR: multiple backends attempting to wait
for pincount 1".

The fix is simple, unset the flag if still set when retrying. That
implies an additional spinlock acquisition/release, but that's unlikely
to matter given the cost of waiting for a cleanup lock.  Alternatively
it'd have been possible to move responsibility for maintaining the
relevant flag to the waiter all together, but that might have had
negative consequences due to possible floods of signals. Besides being
more invasive.

This looks to be a very longstanding bug. The relevant code in
LockBufferForCleanup() hasn't changed materially since its introduction
and ProcWaitForSignal() was documented to return for unrelated reasons
since 8.2.  The master only patch series removing ImmediateInterruptOK
made it much easier to hit though, as ProcSendSignal/ProcWaitForSignal
now uses a latch shared with other tasks.

Per discussion with Kevin Grittner, Tom Lane and me.

Backpatch to all supported branches.

Discussion: 11553.1423805224@sss.pgh.pa.us

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/89629f28959b877c678e6cccce243b0a00d307f8

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   14 ++++++++++++++
1 file changed, 14 insertions(+)


-- 
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: Guard against spurious signals in LockBufferForCleanup.
@ 2015-02-23 15:25  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Andres Freund @ 2015-02-23 15:25 UTC (permalink / raw)
  To: pgsql-committers

Guard against spurious signals in LockBufferForCleanup.

When LockBufferForCleanup() has to wait for getting a cleanup lock on a
buffer it does so by setting a flag in the buffer header and then wait
for other backends to signal it using ProcWaitForSignal().
Unfortunately LockBufferForCleanup() missed that ProcWaitForSignal() can
return for other reasons than the signal it is hoping for. If such a
spurious signal arrives the wait flags on the buffer header will still
be set. That then triggers "ERROR: multiple backends attempting to wait
for pincount 1".

The fix is simple, unset the flag if still set when retrying. That
implies an additional spinlock acquisition/release, but that's unlikely
to matter given the cost of waiting for a cleanup lock.  Alternatively
it'd have been possible to move responsibility for maintaining the
relevant flag to the waiter all together, but that might have had
negative consequences due to possible floods of signals. Besides being
more invasive.

This looks to be a very longstanding bug. The relevant code in
LockBufferForCleanup() hasn't changed materially since its introduction
and ProcWaitForSignal() was documented to return for unrelated reasons
since 8.2.  The master only patch series removing ImmediateInterruptOK
made it much easier to hit though, as ProcSendSignal/ProcWaitForSignal
now uses a latch shared with other tasks.

Per discussion with Kevin Grittner, Tom Lane and me.

Backpatch to all supported branches.

Discussion: 11553.1423805224@sss.pgh.pa.us

Branch
------
REL9_3_STABLE

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

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   14 ++++++++++++++
1 file changed, 14 insertions(+)


-- 
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: Guard against spurious signals in LockBufferForCleanup.
@ 2015-02-23 15:25  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Andres Freund @ 2015-02-23 15:25 UTC (permalink / raw)
  To: pgsql-committers

Guard against spurious signals in LockBufferForCleanup.

When LockBufferForCleanup() has to wait for getting a cleanup lock on a
buffer it does so by setting a flag in the buffer header and then wait
for other backends to signal it using ProcWaitForSignal().
Unfortunately LockBufferForCleanup() missed that ProcWaitForSignal() can
return for other reasons than the signal it is hoping for. If such a
spurious signal arrives the wait flags on the buffer header will still
be set. That then triggers "ERROR: multiple backends attempting to wait
for pincount 1".

The fix is simple, unset the flag if still set when retrying. That
implies an additional spinlock acquisition/release, but that's unlikely
to matter given the cost of waiting for a cleanup lock.  Alternatively
it'd have been possible to move responsibility for maintaining the
relevant flag to the waiter all together, but that might have had
negative consequences due to possible floods of signals. Besides being
more invasive.

This looks to be a very longstanding bug. The relevant code in
LockBufferForCleanup() hasn't changed materially since its introduction
and ProcWaitForSignal() was documented to return for unrelated reasons
since 8.2.  The master only patch series removing ImmediateInterruptOK
made it much easier to hit though, as ProcSendSignal/ProcWaitForSignal
now uses a latch shared with other tasks.

Per discussion with Kevin Grittner, Tom Lane and me.

Backpatch to all supported branches.

Discussion: 11553.1423805224@sss.pgh.pa.us

Branch
------
REL9_2_STABLE

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

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   14 ++++++++++++++
1 file changed, 14 insertions(+)


-- 
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: Guard against spurious signals in LockBufferForCleanup.
@ 2015-02-23 15:26  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Andres Freund @ 2015-02-23 15:26 UTC (permalink / raw)
  To: pgsql-committers

Guard against spurious signals in LockBufferForCleanup.

When LockBufferForCleanup() has to wait for getting a cleanup lock on a
buffer it does so by setting a flag in the buffer header and then wait
for other backends to signal it using ProcWaitForSignal().
Unfortunately LockBufferForCleanup() missed that ProcWaitForSignal() can
return for other reasons than the signal it is hoping for. If such a
spurious signal arrives the wait flags on the buffer header will still
be set. That then triggers "ERROR: multiple backends attempting to wait
for pincount 1".

The fix is simple, unset the flag if still set when retrying. That
implies an additional spinlock acquisition/release, but that's unlikely
to matter given the cost of waiting for a cleanup lock.  Alternatively
it'd have been possible to move responsibility for maintaining the
relevant flag to the waiter all together, but that might have had
negative consequences due to possible floods of signals. Besides being
more invasive.

This looks to be a very longstanding bug. The relevant code in
LockBufferForCleanup() hasn't changed materially since its introduction
and ProcWaitForSignal() was documented to return for unrelated reasons
since 8.2.  The master only patch series removing ImmediateInterruptOK
made it much easier to hit though, as ProcSendSignal/ProcWaitForSignal
now uses a latch shared with other tasks.

Per discussion with Kevin Grittner, Tom Lane and me.

Backpatch to all supported branches.

Discussion: 11553.1423805224@sss.pgh.pa.us

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/25576bee25dd6f48669a523ec54a54192faa734b

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   14 ++++++++++++++
1 file changed, 14 insertions(+)


-- 
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: Guard against spurious signals in LockBufferForCleanup.
@ 2015-02-23 15:26  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Andres Freund @ 2015-02-23 15:26 UTC (permalink / raw)
  To: pgsql-committers

Guard against spurious signals in LockBufferForCleanup.

When LockBufferForCleanup() has to wait for getting a cleanup lock on a
buffer it does so by setting a flag in the buffer header and then wait
for other backends to signal it using ProcWaitForSignal().
Unfortunately LockBufferForCleanup() missed that ProcWaitForSignal() can
return for other reasons than the signal it is hoping for. If such a
spurious signal arrives the wait flags on the buffer header will still
be set. That then triggers "ERROR: multiple backends attempting to wait
for pincount 1".

The fix is simple, unset the flag if still set when retrying. That
implies an additional spinlock acquisition/release, but that's unlikely
to matter given the cost of waiting for a cleanup lock.  Alternatively
it'd have been possible to move responsibility for maintaining the
relevant flag to the waiter all together, but that might have had
negative consequences due to possible floods of signals. Besides being
more invasive.

This looks to be a very longstanding bug. The relevant code in
LockBufferForCleanup() hasn't changed materially since its introduction
and ProcWaitForSignal() was documented to return for unrelated reasons
since 8.2.  The master only patch series removing ImmediateInterruptOK
made it much easier to hit though, as ProcSendSignal/ProcWaitForSignal
now uses a latch shared with other tasks.

Per discussion with Kevin Grittner, Tom Lane and me.

Backpatch to all supported branches.

Discussion: 11553.1423805224@sss.pgh.pa.us

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/87b7fcc87277142f584a9c1646abe52a8a79365d

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   14 ++++++++++++++
1 file changed, 14 insertions(+)


-- 
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-02-23 15:26 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23 15:25 pgsql: Guard against spurious signals in LockBufferForCleanup. Andres Freund <andres@anarazel.de>
2015-02-23 15:25 pgsql: Guard against spurious signals in LockBufferForCleanup. Andres Freund <andres@anarazel.de>
2015-02-23 15:25 pgsql: Guard against spurious signals in LockBufferForCleanup. Andres Freund <andres@anarazel.de>
2015-02-23 15:25 pgsql: Guard against spurious signals in LockBufferForCleanup. Andres Freund <andres@anarazel.de>
2015-02-23 15:26 pgsql: Guard against spurious signals in LockBufferForCleanup. Andres Freund <andres@anarazel.de>
2015-02-23 15:26 pgsql: Guard against spurious signals in LockBufferForCleanup. Andres Freund <andres@anarazel.de>

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