pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
7+ messages / 1 participants
[nested] [flat]

* pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
@ 2020-10-17 20:53  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-10-17 20:53 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In libpq for Windows, call WSAStartup once and WSACleanup not at all.

The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call.  However, if that ever had actual
relevance, it wasn't in this century.  Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash.  Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit 4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.

libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles.  We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge.  It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.

However, the real reason for acting on this is that recent
experiments by Alexander Lakhin suggest that calling WSACleanup
during PQfinish might be triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.

Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.

While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.

If this proves to suppress the fairly-common ecpg test failures
we see on Windows, I'll back-patch, but for now let's just do it
in HEAD and see what happens.

Discussion: https://postgr.es/m/ac976d8c-03df-d6b8-025c-15a2de8d9af1@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7d00a6b2de8ab1e95e052663064defb0bc3022f6

Modified Files
--------------
doc/src/sgml/libpq.sgml           | 15 ---------------
src/bin/pg_dump/parallel.c        | 16 +---------------
src/interfaces/libpq/fe-connect.c | 31 +++++++++++++++++--------------
3 files changed, 18 insertions(+), 44 deletions(-)



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

* pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
@ 2020-10-19 15:24  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-10-19 15:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In libpq for Windows, call WSAStartup once and WSACleanup not at all.

The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call.  However, if that ever had actual
relevance, it wasn't in this century.  Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash.  Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit 4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.

libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles.  We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge.  It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.

However, the real reason for acting on this is that recent
experiments by Alexander Lakhin show that calling WSACleanup
during PQfinish is triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.

Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.

While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.

Back-patch of HEAD commit 7d00a6b2d.

Discussion: https://postgr.es/m/ac976d8c-03df-d6b8-025c-15a2de8d9af1@postgrespro.ru

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/407580aabb831f933234c91991387b2ba3fe2318

Modified Files
--------------
doc/src/sgml/libpq.sgml           | 15 ---------------
src/bin/pg_dump/parallel.c        | 16 +---------------
src/interfaces/libpq/fe-connect.c | 31 +++++++++++++++++--------------
3 files changed, 18 insertions(+), 44 deletions(-)



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

* pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
@ 2020-10-19 15:24  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-10-19 15:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In libpq for Windows, call WSAStartup once and WSACleanup not at all.

The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call.  However, if that ever had actual
relevance, it wasn't in this century.  Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash.  Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit 4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.

libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles.  We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge.  It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.

However, the real reason for acting on this is that recent
experiments by Alexander Lakhin show that calling WSACleanup
during PQfinish is triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.

Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.

While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.

Back-patch of HEAD commit 7d00a6b2d.

Discussion: https://postgr.es/m/ac976d8c-03df-d6b8-025c-15a2de8d9af1@postgrespro.ru

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d2074daebe1699f0d48fa63f6ba196b6426023ad

Modified Files
--------------
doc/src/sgml/libpq.sgml           | 15 ---------------
src/bin/pg_dump/parallel.c        | 16 +---------------
src/interfaces/libpq/fe-connect.c | 31 +++++++++++++++++--------------
3 files changed, 18 insertions(+), 44 deletions(-)



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

* pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
@ 2020-10-19 15:24  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-10-19 15:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In libpq for Windows, call WSAStartup once and WSACleanup not at all.

The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call.  However, if that ever had actual
relevance, it wasn't in this century.  Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash.  Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit 4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.

libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles.  We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge.  It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.

However, the real reason for acting on this is that recent
experiments by Alexander Lakhin show that calling WSACleanup
during PQfinish is triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.

Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.

While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.

Back-patch of HEAD commit 7d00a6b2d.

Discussion: https://postgr.es/m/ac976d8c-03df-d6b8-025c-15a2de8d9af1@postgrespro.ru

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cdc7ace161d39ed788e4e169763c80b58d5bd9c1

Modified Files
--------------
doc/src/sgml/libpq.sgml           | 15 ---------------
src/bin/pg_dump/parallel.c        | 16 +---------------
src/interfaces/libpq/fe-connect.c | 31 +++++++++++++++++--------------
3 files changed, 18 insertions(+), 44 deletions(-)



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

* pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
@ 2020-10-19 15:24  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-10-19 15:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In libpq for Windows, call WSAStartup once and WSACleanup not at all.

The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call.  However, if that ever had actual
relevance, it wasn't in this century.  Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash.  Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit 4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.

libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles.  We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge.  It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.

However, the real reason for acting on this is that recent
experiments by Alexander Lakhin show that calling WSACleanup
during PQfinish is triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.

Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.

While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.

Back-patch of HEAD commit 7d00a6b2d.

Discussion: https://postgr.es/m/ac976d8c-03df-d6b8-025c-15a2de8d9af1@postgrespro.ru

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6670e91078b3cc7927b9a16d2082586bef63b547

Modified Files
--------------
doc/src/sgml/libpq.sgml           | 15 ---------------
src/bin/pg_dump/parallel.c        | 16 +---------------
src/interfaces/libpq/fe-connect.c | 31 +++++++++++++++++--------------
3 files changed, 18 insertions(+), 44 deletions(-)



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

* pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
@ 2020-10-19 15:24  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-10-19 15:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In libpq for Windows, call WSAStartup once and WSACleanup not at all.

The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call.  However, if that ever had actual
relevance, it wasn't in this century.  Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash.  Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit 4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.

libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles.  We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge.  It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.

However, the real reason for acting on this is that recent
experiments by Alexander Lakhin show that calling WSACleanup
during PQfinish is triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.

Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.

While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.

Back-patch of HEAD commit 7d00a6b2d.

Discussion: https://postgr.es/m/ac976d8c-03df-d6b8-025c-15a2de8d9af1@postgrespro.ru

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/883226441d673ffc4d5fbdd57396030e5648155c

Modified Files
--------------
doc/src/sgml/libpq.sgml           | 15 ---------------
src/bin/pg_dump/parallel.c        | 16 +---------------
src/interfaces/libpq/fe-connect.c | 31 +++++++++++++++++--------------
3 files changed, 18 insertions(+), 44 deletions(-)



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

* pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at
@ 2020-10-19 15:24  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-10-19 15:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In libpq for Windows, call WSAStartup once and WSACleanup not at all.

The Windows documentation insists that every WSAStartup call should
have a matching WSACleanup call.  However, if that ever had actual
relevance, it wasn't in this century.  Every remotely-modern Windows
kernel is capable of cleaning up when a process exits without doing
that, and must be so to avoid resource leaks in case of a process
crash.  Moreover, Postgres backends have done WSAStartup without
WSACleanup since commit 4cdf51e64 in 2004, and we've never seen any
indication of a problem with that.

libpq's habit of doing WSAStartup during connection start and
WSACleanup during shutdown is also rather inefficient, since a
series of non-overlapping connection requests leads to repeated,
quite expensive DLL unload/reload cycles.  We document a workaround
for that (having the application call WSAStartup for itself), but
that's just a kluge.  It's also worth noting that it's far from
uncommon for applications to exit without doing PQfinish, and
we've not heard reports of trouble from that either.

However, the real reason for acting on this is that recent
experiments by Alexander Lakhin show that calling WSACleanup
during PQfinish is triggering the symptom we occasionally see
that a process using libpq fails to emit expected stdio output.

Therefore, let's change libpq so that it calls WSAStartup only
once per process, during the first connection attempt, and never
calls WSACleanup at all.

While at it, get rid of the only other WSACleanup call in our code
tree, in pg_dump/parallel.c; that presumably is equally useless.

Back-patch of HEAD commit 7d00a6b2d.

Discussion: https://postgr.es/m/ac976d8c-03df-d6b8-025c-15a2de8d9af1@postgrespro.ru

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6acc31a201d84ff795b0d0f5a4b3a0ec1730347a

Modified Files
--------------
doc/src/sgml/libpq.sgml           | 15 ---------------
src/bin/pg_dump/parallel.c        | 16 +---------------
src/interfaces/libpq/fe-connect.c | 31 +++++++++++++++++--------------
3 files changed, 18 insertions(+), 44 deletions(-)



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


end of thread, other threads:[~2020-10-19 15:24 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17 20:53 pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 15:24 pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 15:24 pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 15:24 pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 15:24 pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 15:24 pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at Tom Lane <tgl@sss.pgh.pa.us>
2020-10-19 15:24 pgsql: In libpq for Windows, call WSAStartup once and WSACleanup not at 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