pgsql: Fix pg_recvlogical upon signal termination - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Fix pg_recvlogical upon signal termination
Date
Msg-id E1qMIOy-000Mgn-1e@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix pg_recvlogical upon signal termination

When pg_recvlogical needs to abort on a signal like SIGINT/SIGTERM, it
is expected to exit cleanly as the code documents.  However, the code
forgot to clean up the state of the connection before leaving.  This
would cause the tool to emit messages like "unexpected termination of
replication stream" error, which is meant for really unexpected
termination or a crash.

The code is refactored to apply the same termination abort operations for
signals, end LSN and keepalive cases, registering a "reason" for the
termination with a message printed under --verbose adapted to the reason
used.

This is arguably a bug, but this has been this way since the tool exists
and the signal termination can now become slower depending on the change
being decoded when the signal is received.

Reported-by: Andres Freund
Author: Bharath Rupireddy
Reviewed-by: Andres Freund, Kyotaro Horiguchi, Cary Huang, Michael
Paquier
Discussion: https://postgr.es/m/20221019213953.htdtzikf4f45ywil@awork3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/47556a0013fa64d44add2760577d49cf2eca4cd0

Modified Files
--------------
src/bin/pg_basebackup/pg_recvlogical.c | 55 ++++++++++++++++++++++++++--------
src/tools/pgindent/typedefs.list       |  1 +
2 files changed, 44 insertions(+), 12 deletions(-)


pgsql-committers by date:

Previous
From: Nathan Bossart
Date:
Subject: pgsql: Support parenthesized syntax for CLUSTER without a table name.
Next
From: Michael Paquier
Date:
Subject: pgsql: Add missing ObjectIdGetDatum() in syscache lookup calls for Oids