| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix error handling in libpqrcv_connect() |
| Date: | 2023-01-24 02:51:00 |
| Message-ID: | [email protected] |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix error handling in libpqrcv_connect()
When libpqrcv_connect (also known as walrcv_connect()) failed, it leaked the
libpq connection. In most paths that's fairly harmless, as the calling process
will exit soon after. But e.g. CREATE SUBSCRIPTION could lead to a somewhat
longer lived leak.
Fix by releasing resources, including the libpq connection, on error.
Add a test exercising the error code path. To make it reliable and safe, the
test tries to connect to port=-1, which happens to fail during connection
establishment, rather than during connection string parsing.
Reviewed-by: Noah Misch <noah(at)leadboat(dot)com>
Discussion: https://postgr.es/m/[email protected]
Backpatch: 11-
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/0a796b8b3e311ea21cf679bf71f39b42e859a686
Modified Files
--------------
.../libpqwalreceiver/libpqwalreceiver.c | 26 +++++++++++++---------
src/test/regress/expected/subscription.out | 10 ++++++++-
src/test/regress/sql/subscription.sql | 9 +++++++-
3 files changed, 32 insertions(+), 13 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2023-01-24 03:27:10 | pgsql: Add helper library for use of libpq inside the server environmen |
| Previous Message | David Rowley | 2023-01-24 00:50:32 | pgsql: Use OFFSET 0 instead of ORDER BY to stop subquery pullup |