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:04:08 +0000 (14:04 +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 6937934445663f859fe46be8b1582e8784e45e44..beb5a1519b647450cc6c64f3a19d03a5b4b6df5b 100644 (file)
@@ -1939,6 +1939,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)
 {
@@ -2088,7 +2092,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")));
@@ -3623,6 +3627,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)
 {