pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix ordering of operations in SyncRepWakeQueue to avoid assertio
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix ordering of operations in SyncRepWakeQueue to avoid assertio
@ 2017-07-12 12:45 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 3+ messages in thread

From: Heikki Linnakangas @ 2017-07-12 12:45 UTC (permalink / raw)
  To: pgsql-committers

Fix ordering of operations in SyncRepWakeQueue to avoid assertion failure.

Commit 14e8803f1 removed the locking in SyncRepWaitForLSN, but that
introduced a race condition, where SyncRepWaitForLSN might see
syncRepState already set to SYNC_REP_WAIT_COMPLETE, but the process was
not yet removed from the queue. That tripped the assertion, that the
process should no longer be in the uqeue. Reorder the operations in
SyncRepWakeQueue to remove the process from the queue first, and update
syncRepState only after that, and add a memory barrier in between to make
sure the operations are made visible to other processes in that order.

Fixes bug #14721 reported by Const Zhang. Analysis and fix by Thomas Munro.
Backpatch down to 9.5, where the locking was removed.

Discussion: https://www.postgresql.org/message-id/20170629023623.1480.26508%40wrigleys.postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/49a3360209ba07d385f1a9e619854bbbe1b7005f

Modified Files
--------------
src/backend/replication/syncrep.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 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] 3+ messages in thread

* pgsql: Fix ordering of operations in SyncRepWakeQueue to avoid assertio
@ 2017-07-12 12:45 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 3+ messages in thread

From: Heikki Linnakangas @ 2017-07-12 12:45 UTC (permalink / raw)
  To: pgsql-committers

Fix ordering of operations in SyncRepWakeQueue to avoid assertion failure.

Commit 14e8803f1 removed the locking in SyncRepWaitForLSN, but that
introduced a race condition, where SyncRepWaitForLSN might see
syncRepState already set to SYNC_REP_WAIT_COMPLETE, but the process was
not yet removed from the queue. That tripped the assertion, that the
process should no longer be in the uqeue. Reorder the operations in
SyncRepWakeQueue to remove the process from the queue first, and update
syncRepState only after that, and add a memory barrier in between to make
sure the operations are made visible to other processes in that order.

Fixes bug #14721 reported by Const Zhang. Analysis and fix by Thomas Munro.
Backpatch down to 9.5, where the locking was removed.

Discussion: https://www.postgresql.org/message-id/20170629023623.1480.26508%40wrigleys.postgresql.org

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/941188a5ff49c4e042ddd4234c35cf0e1bfd7f19

Modified Files
--------------
src/backend/replication/syncrep.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 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] 3+ messages in thread

* pgsql: Fix ordering of operations in SyncRepWakeQueue to avoid assertio
@ 2017-07-12 12:45 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 3+ messages in thread

From: Heikki Linnakangas @ 2017-07-12 12:45 UTC (permalink / raw)
  To: pgsql-committers

Fix ordering of operations in SyncRepWakeQueue to avoid assertion failure.

Commit 14e8803f1 removed the locking in SyncRepWaitForLSN, but that
introduced a race condition, where SyncRepWaitForLSN might see
syncRepState already set to SYNC_REP_WAIT_COMPLETE, but the process was
not yet removed from the queue. That tripped the assertion, that the
process should no longer be in the uqeue. Reorder the operations in
SyncRepWakeQueue to remove the process from the queue first, and update
syncRepState only after that, and add a memory barrier in between to make
sure the operations are made visible to other processes in that order.

Fixes bug #14721 reported by Const Zhang. Analysis and fix by Thomas Munro.
Backpatch down to 9.5, where the locking was removed.

Discussion: https://www.postgresql.org/message-id/20170629023623.1480.26508%40wrigleys.postgresql.org

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9c32c29ee7d32cb849971b0c3a79aaa79a5d8264

Modified Files
--------------
src/backend/replication/syncrep.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 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] 3+ messages in thread


end of thread, other threads:[~2017-07-12 12:45 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-07-12 12:45 pgsql: Fix ordering of operations in SyncRepWakeQueue to avoid assertio Heikki Linnakangas <heikki.linnakangas@iki.fi>
2017-07-12 12:45 pgsql: Fix ordering of operations in SyncRepWakeQueue to avoid assertio Heikki Linnakangas <heikki.linnakangas@iki.fi>
2017-07-12 12:45 pgsql: Fix ordering of operations in SyncRepWakeQueue to avoid assertio Heikki Linnakangas <heikki.linnakangas@iki.fi>

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