Cleanup pgpool main process logging.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 11 Mar 2022 04:40:28 +0000 (13:40 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 11 Mar 2022 04:40:28 +0000 (13:40 +0900)
Downgrade some logs for forking process to not flood the log
file. Also emphasis important events such as failover starting.

src/main/pgpool_main.c
src/test/regression/tests/015.watchdog_master_and_backend_fail/test.sh
src/test/regression/tests/055.backend_all_down/test.sh

index a3c6a4d33b17b8e8f0fc9af2ac5772dacd5f5efb..2f3f4b06501b3c39bfc00f33be87e9e551f03710 100644 (file)
@@ -1694,7 +1694,7 @@ reaper(void)
                                ereport(WARNING,
                                                (errmsg("%s process with pid: %d was terminated by sigkill", exiting_process_name, pid)));
                        else
-                               ereport(LOG,
+                               ereport(DEBUG1,
                                                (errmsg("%s process with pid: %d exits with status %d by signal %d", exiting_process_name, pid, status, WTERMSIG(status))));
 
                        /*
@@ -1708,7 +1708,7 @@ reaper(void)
                        }
                }
                else
-                       ereport(LOG,
+                       ereport(DEBUG1,
                                        (errmsg("%s process with pid: %d exits with status %d", exiting_process_name, pid, status)));
 
                /* if exiting child process was PCP handler */
@@ -1838,7 +1838,7 @@ reaper(void)
                else if (restart_child && new_pid)
                {
                        /* Report if the child was restarted */
-                       ereport(LOG,
+                       ereport(DEBUG1,
                                        (errmsg("fork a new %s process with pid: %d", exiting_process_name, new_pid)));
                }
                else
@@ -2730,16 +2730,20 @@ fork_follow_child(int old_main_node, int new_primary, int old_primary)
                wd_lock_standby(WD_FOLLOW_PRIMARY_LOCK);
                pool_acquire_follow_primary_lock(true, false);
                Req_info->follow_primary_ongoing = true;
-               ereport(LOG,
-                               (errmsg("start triggering follow command.")));
                for (i = 0; i < pool_config->backend_desc->num_backends; i++)
                {
                        BackendInfo *bkinfo;
 
                        bkinfo = pool_get_node_info(i);
                        if (bkinfo->backend_status == CON_DOWN)
+                       {
+                               ereport(LOG,
+                                               (errmsg("=== Starting follow primary command for node %d ===", i)));
                                trigger_failover_command(i, pool_config->follow_primary_command,
                                                                                 old_main_node, new_primary, old_primary);
+                               ereport(LOG,
+                                               (errmsg("=== Follow primary command for node %d ended ===", i)));
+                       }
                }
                Req_info->follow_primary_ongoing = false;
                pool_release_follow_primary_lock(false);
@@ -3870,7 +3874,7 @@ handle_failback_request(FAILOVER_CONTEXT *failover_context, int node_id)
        }
 
        ereport(LOG,
-                       (errmsg("starting fail back. reconnect host %s(%d)",
+                       (errmsg("=== Starting fail back. reconnect host %s(%d) ===",
                                        BACKEND_INFO(node_id).backend_hostname,
                                        BACKEND_INFO(node_id).backend_port)));
 
@@ -3968,7 +3972,7 @@ handle_failover_request(FAILOVER_CONTEXT *failover_context, int node_id)
                                                                                                           VALID_BACKEND(failover_context->node_id_set[i]))))
                {
                        ereport(LOG,
-                                       (errmsg("starting %s. shutdown host %s(%d)",
+                                       (errmsg("=== Starting %s. shutdown host %s(%d) ===",
                                                        (failover_context->reqkind == NODE_QUARANTINE_REQUEST) ? "quarantine" : "degeneration",
                                                        BACKEND_INFO(failover_context->node_id_set[i]).backend_hostname,
                                                        BACKEND_INFO(failover_context->node_id_set[i]).backend_port)));
@@ -4462,7 +4466,7 @@ exec_child_restart(FAILOVER_CONTEXT *failover_context, int node_id)
        if (failover_context->reqkind == NODE_UP_REQUEST)
        {
                ereport(LOG,
-                               (errmsg("failback done. reconnect host %s(%d)",
+                               (errmsg("=== Failback done. reconnect host %s(%d) ===",
                                                BACKEND_INFO(node_id).backend_hostname,
                                                BACKEND_INFO(node_id).backend_port)));
 
@@ -4483,24 +4487,26 @@ exec_child_restart(FAILOVER_CONTEXT *failover_context, int node_id)
        else if (failover_context->reqkind == PROMOTE_NODE_REQUEST)
        {
                ereport(LOG,
-                               (errmsg("promotion done. promoted host %s(%d)",
+                               (errmsg("=== Promotion done. promoted host %s(%d) ===",
                                                BACKEND_INFO(node_id).backend_hostname,
                                                BACKEND_INFO(node_id).backend_port)));
        }
        else
        {
+#ifdef NOT_USED
                /*
                 * Temporary black magic. Without this regression 055 does not
                 * finish
                 */
-               fprintf(stderr, "%s done. shutdown host %s(%d)",
-                               (failover_context->reqkind == NODE_DOWN_REQUEST) ? "failover" : "quarantine",
+               fprintf(stderr, "=== %s done. shutdown host %s(%d) ===",
+                               (failover_context->reqkind == NODE_DOWN_REQUEST) ? "Failover" : "Quarantine",
                                BACKEND_INFO(node_id).backend_hostname,
                                BACKEND_INFO(node_id).backend_port);
+#endif
 
                ereport(LOG,
-                               (errmsg("%s done. shutdown host %s(%d)",
-                                               (failover_context->reqkind == NODE_DOWN_REQUEST) ? "failover" : "quarantine",
+                               (errmsg("=== %s done. shutdown host %s(%d) ===",
+                                               (failover_context->reqkind == NODE_DOWN_REQUEST) ? "Failover" : "Quarantine",
                                                BACKEND_INFO(node_id).backend_hostname,
                                                BACKEND_INFO(node_id).backend_port)));
        }
index c69bfe737658dea47584af9b8122e20a843bfeb6..3b517a98d9b1f752cef1c07a34e6dfdf04be2d5e 100755 (executable)
@@ -141,7 +141,7 @@ sleep 5
 echo "Waiting for the standby to execute failover..."
 for i in 1 2 3 4 5 6 7 8 9 10
 do
-       grep " failover done" $STANDBY_DIR/log/pgpool.log > /dev/null 2>&1
+       grep " Failover done" $STANDBY_DIR/log/pgpool.log > /dev/null 2>&1
        if [ $? = 0 ];then
                success_count=$(( success_count + 1 ))
                echo "Standby became new leader successfully."
index a77a2472f3ffd068b242f29093d80837ef39f8ae..100ec5e5a737681fb1f2b55fe2acf4ac65f5c3a6 100755 (executable)
@@ -32,7 +32,7 @@ sh pgpool.sh
 
 while true
 do
-       grep "failover done. shutdown host $PGSOCKET_DIR(11003)" log/pgpool.log > /dev/null 2>&1
+       grep "Failover done. shutdown host $PGSOCKET_DIR(11003)" log/pgpool.log > /dev/null 2>&1
        if [ $? = 0 ];then
                break;
        fi