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 04:55:42 +0000 (13:55 +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 d57d83526c7399fbe6820bec9f130ac1af7d8c64..31aec1735f45464ca4ea13299aa73bdebc8fd41a 100644 (file)
@@ -1983,6 +1983,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)
 {
@@ -2133,7 +2137,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")));
@@ -3691,6 +3695,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)
 {