pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion
@ 2016-01-03 18:56 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-01-03 18:56 UTC (permalink / raw)
  To: pgsql-committers

Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition.

pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()
as being a reason to block ever since the current implementation was
introduced in commit a4c40f140d23cefb.  However, so far as one can tell
from Microsoft's documentation, that is just wrong: what it means is
graceful connection closure (in stream protocols) or receipt of a
zero-length message (in message protocols), and neither case should result
in blocking here.  The only reason the code worked at all was that control
then fell into the retry loop, which did *not* treat zero bytes specially,
so we'd get out after only wasting some cycles.  But as of 9.5 we do not
normally reach the retry loop and so the bug is exposed, as reported by
Shay Rojansky and diagnosed by Andres Freund.

Remove the unnecessary test on the byte count, and rearrange the code
in the retry loop so that it looks identical to the initial sequence.

Back-patch to 9.5.  The code is wrong all the way back, AFAICS, but
since it's relatively harmless in earlier branches we'll leave it alone.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/90e61df8130dc7051a108ada1219fb0680cb3eb6

Modified Files
--------------
src/backend/port/win32/socket.c |   37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 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 treatment of *lpNumberOfBytesRecvd == 0: that's a completion
@ 2016-01-03 18:56 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-01-03 18:56 UTC (permalink / raw)
  To: pgsql-committers

Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition.

pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()
as being a reason to block ever since the current implementation was
introduced in commit a4c40f140d23cefb.  However, so far as one can tell
from Microsoft's documentation, that is just wrong: what it means is
graceful connection closure (in stream protocols) or receipt of a
zero-length message (in message protocols), and neither case should result
in blocking here.  The only reason the code worked at all was that control
then fell into the retry loop, which did *not* treat zero bytes specially,
so we'd get out after only wasting some cycles.  But as of 9.5 we do not
normally reach the retry loop and so the bug is exposed, as reported by
Shay Rojansky and diagnosed by Andres Freund.

Remove the unnecessary test on the byte count, and rearrange the code
in the retry loop so that it looks identical to the initial sequence.

Back-patch to 9.5.  The code is wrong all the way back, AFAICS, but
since it's relatively harmless in earlier branches we'll leave it alone.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/29692bdbb1dffed0eda38ad8268655425a7dcdf5

Modified Files
--------------
src/backend/port/win32/socket.c |   37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 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 treatment of *lpNumberOfBytesRecvd == 0: that's a completion
@ 2016-01-04 22:41 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-01-04 22:41 UTC (permalink / raw)
  To: pgsql-committers

Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition.

pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()
as being a reason to block ever since the current implementation was
introduced in commit a4c40f140d23cefb.  However, so far as one can tell
from Microsoft's documentation, that is just wrong: what it means is
graceful connection closure (in stream protocols) or receipt of a
zero-length message (in message protocols), and neither case should result
in blocking here.  The only reason the code worked at all was that control
then fell into the retry loop, which did *not* treat zero bytes specially,
so we'd get out after only wasting some cycles.  But as of 9.5 we do not
normally reach the retry loop and so the bug is exposed, as reported by
Shay Rojansky and diagnosed by Andres Freund.

Remove the unnecessary test on the byte count, and rearrange the code
in the retry loop so that it looks identical to the initial sequence.

Back-patch of commit 90e61df8130dc7051a108ada1219fb0680cb3eb6.  The
original plan was to apply this only to 9.5 and up, but after discussion
and buildfarm testing, it seems better to back-patch.  The noblock code
path has been at risk of this problem since it was introduced (in 9.0);
if it did happen in pre-9.5 branches, the symptom would be that a walsender
would wait indefinitely rather than noticing a loss of connection.  While
we lack proof that the case has been seen in the field, it seems possible
that it's happened without being reported.

Branch
------
REL9_4_STABLE

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

Modified Files
--------------
src/backend/port/win32/socket.c |   37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 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 treatment of *lpNumberOfBytesRecvd == 0: that's a completion
@ 2016-01-04 22:41 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-01-04 22:41 UTC (permalink / raw)
  To: pgsql-committers

Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition.

pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()
as being a reason to block ever since the current implementation was
introduced in commit a4c40f140d23cefb.  However, so far as one can tell
from Microsoft's documentation, that is just wrong: what it means is
graceful connection closure (in stream protocols) or receipt of a
zero-length message (in message protocols), and neither case should result
in blocking here.  The only reason the code worked at all was that control
then fell into the retry loop, which did *not* treat zero bytes specially,
so we'd get out after only wasting some cycles.  But as of 9.5 we do not
normally reach the retry loop and so the bug is exposed, as reported by
Shay Rojansky and diagnosed by Andres Freund.

Remove the unnecessary test on the byte count, and rearrange the code
in the retry loop so that it looks identical to the initial sequence.

Back-patch of commit 90e61df8130dc7051a108ada1219fb0680cb3eb6.  The
original plan was to apply this only to 9.5 and up, but after discussion
and buildfarm testing, it seems better to back-patch.  The noblock code
path has been at risk of this problem since it was introduced (in 9.0);
if it did happen in pre-9.5 branches, the symptom would be that a walsender
would wait indefinitely rather than noticing a loss of connection.  While
we lack proof that the case has been seen in the field, it seems possible
that it's happened without being reported.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/0f527f73bd24710b9eeadc60d930bb8ab9adb213

Modified Files
--------------
src/backend/port/win32/socket.c |   37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 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 treatment of *lpNumberOfBytesRecvd == 0: that's a completion
@ 2016-01-04 22:41 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-01-04 22:41 UTC (permalink / raw)
  To: pgsql-committers

Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition.

pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()
as being a reason to block ever since the current implementation was
introduced in commit a4c40f140d23cefb.  However, so far as one can tell
from Microsoft's documentation, that is just wrong: what it means is
graceful connection closure (in stream protocols) or receipt of a
zero-length message (in message protocols), and neither case should result
in blocking here.  The only reason the code worked at all was that control
then fell into the retry loop, which did *not* treat zero bytes specially,
so we'd get out after only wasting some cycles.  But as of 9.5 we do not
normally reach the retry loop and so the bug is exposed, as reported by
Shay Rojansky and diagnosed by Andres Freund.

Remove the unnecessary test on the byte count, and rearrange the code
in the retry loop so that it looks identical to the initial sequence.

Back-patch of commit 90e61df8130dc7051a108ada1219fb0680cb3eb6.  The
original plan was to apply this only to 9.5 and up, but after discussion
and buildfarm testing, it seems better to back-patch.  The noblock code
path has been at risk of this problem since it was introduced (in 9.0);
if it did happen in pre-9.5 branches, the symptom would be that a walsender
would wait indefinitely rather than noticing a loss of connection.  While
we lack proof that the case has been seen in the field, it seems possible
that it's happened without being reported.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/9b2eacba79916df5f3b436e226531e5891c633bc

Modified Files
--------------
src/backend/port/win32/socket.c |   37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 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 treatment of *lpNumberOfBytesRecvd == 0: that's a completion
@ 2016-01-04 22:41 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-01-04 22:41 UTC (permalink / raw)
  To: pgsql-committers

Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition.

pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()
as being a reason to block ever since the current implementation was
introduced in commit a4c40f140d23cefb.  However, so far as one can tell
from Microsoft's documentation, that is just wrong: what it means is
graceful connection closure (in stream protocols) or receipt of a
zero-length message (in message protocols), and neither case should result
in blocking here.  The only reason the code worked at all was that control
then fell into the retry loop, which did *not* treat zero bytes specially,
so we'd get out after only wasting some cycles.  But as of 9.5 we do not
normally reach the retry loop and so the bug is exposed, as reported by
Shay Rojansky and diagnosed by Andres Freund.

Remove the unnecessary test on the byte count, and rearrange the code
in the retry loop so that it looks identical to the initial sequence.

Back-patch of commit 90e61df8130dc7051a108ada1219fb0680cb3eb6.  The
original plan was to apply this only to 9.5 and up, but after discussion
and buildfarm testing, it seems better to back-patch.  The noblock code
path has been at risk of this problem since it was introduced (in 9.0);
if it did happen in pre-9.5 branches, the symptom would be that a walsender
would wait indefinitely rather than noticing a loss of connection.  While
we lack proof that the case has been seen in the field, it seems possible
that it's happened without being reported.

Branch
------
REL9_1_STABLE

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

Modified Files
--------------
src/backend/port/win32/socket.c |   37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 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:[~2016-01-04 22:41 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-03 18:56 pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion Tom Lane <tgl@sss.pgh.pa.us>
2016-01-03 18:56 pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion Tom Lane <tgl@sss.pgh.pa.us>
2016-01-04 22:41 pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion Tom Lane <tgl@sss.pgh.pa.us>
2016-01-04 22:41 pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion Tom Lane <tgl@sss.pgh.pa.us>
2016-01-04 22:41 pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion Tom Lane <tgl@sss.pgh.pa.us>
2016-01-04 22:41 pgsql: Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion Tom Lane <tgl@sss.pgh.pa.us>

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