Fix watchdog to print inappropriate NOTICE message.
authorTatsuo Ishii <ishii@postgresql.org>
Fri, 25 Jul 2025 04:55:42 +0000 (13:55 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Fri, 25 Jul 2025 05:06:28 +0000 (14:06 +0900)
read_ipc_socket_and_process() printed a notice message every time when
it wrote commands to IPC socket even if it was successful. Fix this to
print the notice message only when the write failed.

The reason why this bug was not recognized is, the message appears
only when log_min_messages is set to notice or higher.

Discussion: https://github.com/pgpool/pgpool2/issues/121
Backpatch-through: v4.2

src/watchdog/watchdog.c

index 2c1baf6731448d206cb5d804cf3a722c2e07882c..f9a98a6ceb4bc5cd7e3d14d3113efff57149705e 100644 (file)
@@ -1853,6 +1853,10 @@ read_sockets(fd_set *rmask, int pending_fds_count)
        return count;
 }
 
+/*
+ * write watchdog IP command along with result data
+ * returns true on success
+ */
 static bool
 write_ipc_command_with_result_data(WDCommandData * ipcCommand, char type, char *data, int len)
 {
@@ -2002,7 +2006,7 @@ read_ipc_socket_and_process(int sock, bool *remove_socket)
                        data_len = strlen(data) + 1;
                }
 
-               if (write_ipc_command_with_result_data(ipcCommand, res_type, data, data_len))
+               if (!write_ipc_command_with_result_data(ipcCommand, res_type, data, data_len))
                {
                        ereport(NOTICE,
                                        (errmsg("error writing to IPC socket")));
@@ -3500,6 +3504,10 @@ update_successful_outgoing_cons(fd_set *wmask, int pending_fds_count)
        return count;
 }
 
+/*
+ * write packet to watchdog communication socket
+ * returns true on success.
+ */
 static bool
 write_packet_to_socket(int sock, WDPacketData * pkt, bool ipcPacket)
 {