pgpool2.git / summary / log / commit / refs

commit    b9ed6eb9e8f9945d7a4e9665c0ef20a9d70c9670
Author:   Muhammad Usama <m.usama@gmail.com>
Date:     Tue Dec 10 12:37:27 2013 +0000

    fixing the pgpool main process loop to properly integrating it with the
    new exception and memory manager. Also changing some of the free() calls
    to pfree(), which were mistakenly left out and were caught by the regression test.


src/include/pool.h | 13 + src/main/main.c | 12 +- src/main/pgpool_main.c | 366 ++++++++++++++------------ src/main/pool_globals.c | 1 + src/protocol/pool_process_query.c | 63 +---- src/streaming_replication/pool_worker_child.c | 29 +- src/system_db/pool_system.c | 28 +- 7 files changed, 267 insertions(+), 245 deletions(-) diff --git a/src/include/pool.h b/src/include/pool.h index d0135552d..b478290a8 100644 --- a/src/include/pool.h +++ b/src/include/pool.h @@ -430,6 +430,19 @@ typedef enum extern ProcessType processType; +typedef enum +{ + INITIALIZING, + PERFORMING_HEALTH_CHECK, + PERFORMING_SYSDB_CHECK, + SLEEPING, + WAITIG_FOR_CONNECTION, + BACKEND_CONNECTING, + PROCESSING +} ProcessState; + +extern ProcessState processState; + extern POOL_CONNECTION_POOL *pool_connection_pool; /* connection pool */ extern volatile sig_atomic_t backend_timer_expired; /* flag for connection closed timer is expired */ extern volatile sig_atomic_t health_check_timer_expired; /* non 0 if health check timer expired */ diff --git a/src/main/main.c b/src/main/main.c index 586dffb02..50055505e 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -472,17 +472,17 @@ static int read_pid_file(void) } if ((readlen = read(fd, pidbuf, sizeof(pidbuf))) == -1) { - pool_error("could not read pid file as %s. reason: %s", - pool_config->pid_file_name, strerror(errno)); close(fd); - return -1; + ereport(FATAL, + (errmsg("could not read pid file as \"%s\". reason: %s", + pool_config->pid_file_name, strerror(errno)))); } else if (readlen == 0) { - pool_error("EOF detected while reading pid file as %s. reason: %s", - pool_config->pid_file_name, strerror(errno)); close(fd); - return -1; + ereport(FATAL, + (errmsg("EOF detected while reading pid file \"%s\". reason: %s", + pool_config->pid_file_name, strerror(errno)))); } close(fd); return(atoi(pidbuf)); diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c index 5c73d02fa..ad27dbff0 100644 --- a/src/main/pgpool_main.c +++ b/src/main/pgpool_main.c @@ -92,6 +92,10 @@ #define PGPOOLMAXLITSENQUEUELENGTH 10000 + +static int process_backend_health_check_failure(int health_check_node_id, int retrycnt); +static bool do_health_check(bool use_template_db, volatile int *health_check_node_id); + static void FileUnlink(int code, Datum path); static int write_status_file(void); static pid_t pcp_fork_a_child(int unix_fd, int inet_fd, char *pcp_conf_file); @@ -117,7 +121,6 @@ static RETSIGTYPE reload_config_handler(int sig); static RETSIGTYPE health_check_timer_handler(int sig); static RETSIGTYPE wakeup_handler(int sig); -static int health_check(void); static void initialize_shared_mem_objects(void); static int trigger_failover_command(int node, const char *command_line, int old_master, int new_master, int old_primary); @@ -175,18 +178,21 @@ int my_master_node_id; /* Master node id buffer */ /* * pgpool main program */ + int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps) { int i; - int retrycnt; - int sys_retrycnt; - bool retrying; - MemoryContext MainLoopMemoryContext; + volatile int health_check_node_id = 0; + volatile bool use_template_db = false; + volatile int retrycnt; + volatile int sys_retrycnt; + MemoryContext MainLoopMemoryContext; sigjmp_buf local_sigjmp_buf; /* Set the process type variable */ processType = PT_MAIN; + processState = INITIALIZING; /* * Restore previous backend status if possible @@ -283,7 +289,6 @@ int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps) retrycnt = 0; /* reset health check retry counter */ sys_retrycnt = 0; /* reset SystemDB health check retry counter */ - retrying = false; /* Save primary node id */ Req_info->primary_node_id = find_primary_node(); @@ -294,6 +299,54 @@ int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps) error_context_stack = NULL; EmitErrorReport(); FlushErrorState(); + POOL_SETMASK(&BlockSig); + + /* Check if we are failed during health check + * perform the necessary actions in case + */ + if(processState == PERFORMING_HEALTH_CHECK) + { + if(errno != EINTR || health_check_timer_expired) + { + if(use_template_db == false) + { + /* Health check was performed on 'postgres' database + * lets try to perform health check with template1 db + * before marking the health check as failed + */ + use_template_db = true; + + } + else + { + retrycnt++; + if(process_backend_health_check_failure(health_check_node_id, retrycnt)) + { + health_check_node_id = 0; + use_template_db = false; + } + } + } + } + else if(processState == PERFORMING_SYSDB_CHECK) + { + if ( errno != EINTR || health_check_timer_expired) + { + sys_retrycnt++; + pool_signal(SIGALRM, SIG_IGN); + CLEAR_ALARM; + + if (sys_retrycnt > NUM_BACKENDS) + { + pool_log("set SystemDB down status"); + SYSDB_STATUS = CON_DOWN; + sys_retrycnt = 0; + } + int sleep_time = pool_config->health_check_period/NUM_BACKENDS; + pool_debug("retry sleep time: %d seconds", sleep_time); + pool_sleep(sleep_time); + } + } } /* We can now handle ereport(ERROR) */ PG_exception_stack = &local_sigjmp_buf; @@ -301,20 +354,17 @@ int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps) /* This is the main loop */ for (;;) { + bool all_nodes_healthy; CHECK_REQUEST; + /* do we need health checking for PostgreSQL? */ if (pool_config->health_check_period > 0) { - int sts; - int sys_sts = 0; - unsigned int sleep_time; - unsigned int max_retries; - /* rest per iteration memory context */ MemoryContextSwitchTo(MainLoopMemoryContext); MemoryContextResetAndDeleteChildren(MainLoopMemoryContext); - if (retrycnt == 0) + if (retrycnt == 0 && !use_template_db) ereport(LOG, (errmsg("starting health check"))); else @@ -337,91 +387,31 @@ int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps) */ errno = 0; health_check_timer_expired = 0; - POOL_SETMASK(&UnBlockSig); - sts = health_check(); - POOL_SETMASK(&BlockSig); + if (pool_config->parallel_mode) - sys_sts = system_db_health_check(); - - if ( (sts > 0 || sys_sts < 0) && (errno != EINTR || health_check_timer_expired)) { - if(sts > 0 ) /* Backend connection failed */ - { - sts--; - retrycnt++; - pool_signal(SIGALRM, SIG_IGN); /* Cancel timer */ - CLEAR_ALARM; + processState = PERFORMING_SYSDB_CHECK; + system_db_health_check(); + sys_retrycnt = 0; + errno = 0; + } - max_retries = pool_config->parallel_mode?NUM_BACKENDS:pool_config->health_check_max_retries; - - if (!pool_config->parallel_mode && POOL_DISALLOW_TO_FAILOVER(BACKEND_INFO(sts).flag)) - { - ereport(LOG, - (errmsg("health_check: %d failover is canceled because failover is disallowed", sts))); - } - if (retrycnt > max_retries) - { - /* retry count over */ - ereport(LOG, - (errmsg("set %d th backend down status", sts))); - Req_info->kind = NODE_DOWN_REQUEST; - Req_info->node_id[0] = sts; - health_check_timer_expired = 0; - failover(); - if (pool_config->parallel_mode) - retrycnt = 0; - retrying = false; - } - else - { - /* continue to retry */ - if (pool_config->parallel_mode) - sleep_time = pool_config->health_check_period/NUM_BACKENDS; - else - sleep_time = pool_config->health_check_retry_delay; + POOL_SETMASK(&UnBlockSig); - ereport(DEBUG2, - (errmsg("retry sleep time: %d seconds", sleep_time))); + processState = PERFORMING_HEALTH_CHECK; + all_nodes_healthy = do_health_check(use_template_db,&health_check_node_id); + POOL_SETMASK(&BlockSig); - pool_sleep(sleep_time); - continue; - } - } - - if (sys_sts < 0) /* SystemDB is down */ - { - sys_retrycnt++; - - pool_signal(SIGALRM, SIG_IGN); - CLEAR_ALARM; + health_check_node_id = 0; + use_template_db = false; + retrycnt = 0; - if (sys_retrycnt > NUM_BACKENDS) - { - ereport(LOG, - (errmsg("set SystemDB down status"))); - SYSDB_STATUS = CON_DOWN; - sys_retrycnt = 0; - } - else if (sts == 0) /* goes to sleep only when SystemDB alone was down */ - { - sleep_time = pool_config->health_check_period/NUM_BACKENDS; - pool_debug("retry sleep time: %d seconds", sleep_time); - pool_sleep(sleep_time); - continue; - } - } - } - else - { - /* success. reset retry count */ - retrycnt = 0; - if (retrying) - { - ereport(LOG, - (errmsg("after some retrying backend returned to healthy state"))); - retrying = false; - } - } + if (all_nodes_healthy) + ereport(LOG, + (errmsg("after retry %d, All backends are returned to healthy state",retrycnt))); + + + processState = SLEEPING; if (pool_config->health_check_timeout > 0) { @@ -429,12 +419,11 @@ int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps) pool_signal(SIGALRM, SIG_IGN); CLEAR_ALARM; } - - sleep_time = pool_config->health_check_period; - pool_sleep(sleep_time); + pool_sleep(pool_config->health_check_period); } else /* Health Check is not enable and we have not much to do */ { + processState = SLEEPING; for (;;) { int r; @@ -450,6 +439,57 @@ int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps) } } +/* + * Function process the backend node failure captured by the health check + * since this function is called from the exception handler so ereport(ERROR) + * is not allowed from this function + * Function returns non zero if failover is performed and 0 otherwise. + */ +static int +process_backend_health_check_failure(int health_check_node_id, int retrycnt) +{ + /* + * health check is failed on template1 database as well + */ + int sleep_time = pool_config->parallel_mode ? + pool_config->health_check_period/NUM_BACKENDS : pool_config->health_check_retry_delay; + + int health_check_max_retries = pool_config->parallel_mode ? + (NUM_BACKENDS - 1) : pool_config->health_check_retry_delay; + + pool_signal(SIGALRM, SIG_IGN); /* Cancel timer */ + CLEAR_ALARM; + + if (retrycnt <= health_check_max_retries) + { + /* Keep retrying and sleep a little in between */ + ereport(DEBUG1, + (errmsg("Sleeping for %d seconds from process backend health check failure", sleep_time), + errdetail("health check failed retry no is %d while max retries are %d",retrycnt,health_check_max_retries) )); + + pool_sleep(sleep_time); + } + else + { + /* No more retries left, proceed to failover if allowed */ + if ((!pool_config->parallel_mode) && + POOL_DISALLOW_TO_FAILOVER(BACKEND_INFO(health_check_node_id).flag)) + { + pool_log("health check failed on node %d but failover is disallowed for the node", health_check_node_id); + } + else + { + pool_log("setting backend node %d status to NODE DOWN", health_check_node_id); + Req_info->kind = NODE_DOWN_REQUEST; + Req_info->node_id[0] = health_check_node_id; + health_check_timer_expired = 0; + failover(); + return 1; + /* need to distribute this info to children ??*/ + } + } + return 0; +} /* * fork a child for PCP */ @@ -597,7 +637,6 @@ static int create_inet_domain_socket(const char *hostname, const int port) ereport(FATAL, (errmsg("failed to create INET domain socket"), errdetail("socket error \"%s\"",strerror(errno)))); -// myexit(1); } if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one))) == -1) @@ -1484,31 +1523,38 @@ static RETSIGTYPE health_check_timer_handler(int sig) } + /* - * Check if we can connect to the backend - * returns 0 for OK. otherwise returns backend id + 1 + * do_health_check() performs the health check on all backend nodes. + * The inout parameter health_check_node_id is the starting backend + * node number for health check and when the function returns or + * exits with an error health_check_node_id contains the value + * of last backend node number on which health check was performed. + * + * Function returns false if all backend nodes are down and true if all + * backend nodes are in healthy state */ -static int health_check(void) +static bool +do_health_check(bool use_template_db, volatile int *health_check_node_id) { POOL_CONNECTION_POOL_SLOT *slot; BackendInfo *bkinfo; - static bool is_first = true; static char *dbname; int i; + bool all_nodes_healthy = false; /* Do not execute health check during recovery */ if (*InRecovery) - return 0; + return false; - Retry: + dbname = use_template_db ? "template1" : "postgres"; /* - * First we try with "postgres" database. + * Start checking the backed nodes starting from the + * previously failed node */ - if (is_first) - dbname = "postgres"; - - for (i=0;i<pool_config->backend_desc->num_backends;i++) + for (i=*health_check_node_id;i<pool_config->backend_desc->num_backends;i++) { + *health_check_node_id = i; /* * Make sure that health check timer has not been expired. * Before called health_check(), health_check_timer_expired is @@ -1517,56 +1563,36 @@ static int health_check(void) */ if (health_check_timer_expired) { - ereport(DEBUG1, - (errmsg("health check timer has been already expired before attempting to connect to %d th backend", i))); - return i+1; + ereport(ERROR, + (errmsg("health check timer has been already expired before attempting to connect backend node %d", i))); } bkinfo = pool_get_node_info(i); ereport(DEBUG1, - (errmsg("health_check: %d th DB node status: %d", i, bkinfo->backend_status))); + (errmsg("Backend DB node %d status is %d", i, bkinfo->backend_status))); if (bkinfo->backend_status == CON_UNUSED || bkinfo->backend_status == CON_DOWN) continue; + all_nodes_healthy = true; + ereport(DEBUG1, + (errmsg("Trying to make persistent DB connection to backend node %d having status %d", i, bkinfo->backend_status))); + slot = make_persistent_db_connection(bkinfo->backend_hostname, bkinfo->backend_port, dbname, pool_config->health_check_user, pool_config->health_check_password, false); - if (is_first) - is_first = false; + ereport(DEBUG1, + (errmsg("persistent DB connection to backend node %d having status %d is successful", i, bkinfo->backend_status))); - if (!slot) - { - /* - * Retry with template1 unless health check timer is expired. - */ - if (!strcmp(dbname, "postgres") && health_check_timer_expired == 0) - { - dbname = "template1"; - goto Retry; - } - else - { - pool_error("health check failed. %d th host %s at port %d is down", - i, - bkinfo->backend_hostname, - bkinfo->backend_port); - return i+1; - } - } - else - { - discard_persistent_db_connection(slot); - } + discard_persistent_db_connection(slot); } - - return 0; + return all_nodes_healthy; } /* @@ -2007,39 +2033,51 @@ static int find_primary_node(void) * Check to see if this is a standby node or not. */ is_standby = false; + PG_TRY(); + { - bkinfo = pool_get_node_info(i); - s = make_persistent_db_connection(bkinfo->backend_hostname, + bkinfo = pool_get_node_info(i); + s = make_persistent_db_connection(bkinfo->backend_hostname, bkinfo->backend_port, "postgres", pool_config->sr_check_user, pool_config->sr_check_password, true); - if (!s) - { - pool_error("find_primary_node: make_persistent_connection failed"); - return -1; - } - con = s->con; - status = do_query(con, "SELECT pg_is_in_recovery()", + if (!s) + { + pool_error("find_primary_node: make_persistent_connection failed"); + return -1; + } + con = s->con; + status = do_query(con, "SELECT pg_is_in_recovery()", &res, PROTO_MAJOR_V3); - if (res->numrows <= 0) - { - pool_log("find_primary_node: do_query returns no rows"); - } - if (res->data[0] == NULL) - { - pool_log("find_primary_node: do_query returns no data"); - } - if (res->nullflags[0] == -1) - { - pool_log("find_primary_node: do_query returns NULL"); - } - if (res->data[0] && !strcmp(res->data[0], "t")) - { - is_standby = true; - } - free_select_result(res); - discard_persistent_db_connection(s); + if (res->numrows <= 0) + { + pool_log("find_primary_node: do_query returns no rows"); + } + if (res->data[0] == NULL) + { + pool_log("find_primary_node: do_query returns no data"); + } + if (res->nullflags[0] == -1) + { + pool_log("find_primary_node: do_query returns NULL"); + } + if (res->data[0] && !strcmp(res->data[0], "t")) + { + is_standby = true; + } + free_select_result(res); + discard_persistent_db_connection(s); + } + PG_CATCH(); + { + ErrorData *edata; + edata = CopyErrorData(); + FlushErrorState(); + printf("%s",edata->message); + return -1; + } + PG_END_TRY(); /* * If this is a standby, we continue to look for primary node. diff --git a/src/main/pool_globals.c b/src/main/pool_globals.c index 6457be692..208e0e0da 100644 --- a/src/main/pool_globals.c +++ b/src/main/pool_globals.c @@ -26,3 +26,4 @@ int debug = 0; /* non 0 if debug option is given (-d). pcp only */ pid_t mypid; /* pgpool parent process id */ bool run_as_pcp_child; ProcessType processType; +ProcessState processState; diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c index e332b41dd..d04532d65 100644 --- a/src/protocol/pool_process_query.c +++ b/src/protocol/pool_process_query.c @@ -2307,7 +2307,7 @@ void free_select_result(POOL_SELECT_RESULT *result) return; if (result->nullflags) - free(result->nullflags); + pfree(result->nullflags); if (result->data) { @@ -2317,11 +2317,11 @@ void free_select_result(POOL_SELECT_RESULT *result) for (j=0;j<result->rowdesc->num_attrs;j++) { if (result->data[index]) - free(result->data[index]); + pfree(result->data[index]); index++; } } - free(result->data); + pfree(result->data); } if (result->rowdesc) @@ -2331,14 +2331,14 @@ void free_select_result(POOL_SELECT_RESULT *result) for(i=0;i<result->rowdesc->num_attrs;i++) { if (result->rowdesc->attrinfo[i].attrname) - free(result->rowdesc->attrinfo[i].attrname); + pfree(result->rowdesc->attrinfo[i].attrname); } - free(result->rowdesc->attrinfo); + pfree(result->rowdesc->attrinfo); } - free(result->rowdesc); + pfree(result->rowdesc); } - free(result); + pfree(result); } /* @@ -2662,12 +2662,7 @@ POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT * if (num_fields > 0) { rowdesc->num_attrs = num_fields; - attrinfo = malloc(sizeof(*attrinfo)*num_fields); - if (!attrinfo) - { - pool_error("do_query: malloc failed"); - return POOL_ERROR; - } + attrinfo = palloc(sizeof(*attrinfo)*num_fields); rowdesc->attrinfo = attrinfo; /* extract attribute info */ @@ -2676,12 +2671,7 @@ POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT * if (major == PROTO_MAJOR_V3) { len = strlen(p) + 1; - attrinfo->attrname = malloc(len); - if (!attrinfo->attrname) - { - pool_error("do_query: malloc failed"); - return POOL_ERROR; - } + attrinfo->attrname = palloc(len); memcpy(attrinfo->attrname, p, len); p += len; memcpy(&intval, p, sizeof(int)); @@ -2704,12 +2694,7 @@ POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT * else { p = pool_read_string(backend, &len, 0); - attrinfo->attrname = malloc(len); - if (!attrinfo->attrname) - { - pool_error("do_query: malloc failed"); - return POOL_ERROR; - } + attrinfo->attrname = palloc(len); memcpy(attrinfo->attrname, p, len); if (pool_read(backend, &intval, sizeof(int)) < 0) { @@ -2777,12 +2762,7 @@ POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT * if (len > 0) /* NOT NULL? */ { - res->data[num_data] = malloc(len + 1); - if (!res->data[num_data]) - { - pool_error("do_query: malloc failed"); - return POOL_ERROR; - } + res->data[num_data] = palloc(len + 1); memcpy(res->data[num_data], p, len); *(res->data[num_data] + len) = '\0'; @@ -2810,12 +2790,7 @@ POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT * if (len > 0) { p = pool_read2(backend, len); - res->data[num_data] = malloc(len + 1); - if (!res->data[num_data]) - { - pool_error("do_query: malloc failed"); - return POOL_ERROR; - } + res->data[num_data] = palloc(len + 1); memcpy(res->data[num_data], p, len); *(res->data[num_data] + len) = '\0'; if (res->data[num_data] == NULL) @@ -2837,20 +2812,10 @@ POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT * if (num_data % DO_QUERY_ALLOC_NUM == 0) { - res->nullflags = realloc(res->nullflags, + res->nullflags = repalloc(res->nullflags, (num_data/DO_QUERY_ALLOC_NUM +1)*DO_QUERY_ALLOC_NUM*sizeof(int)); - if (!res->nullflags) - { - pool_error("do_query: malloc failed"); - return POOL_ERROR; - } - res->data = realloc(res->data, + res->data = repalloc(res->data, (num_data/DO_QUERY_ALLOC_NUM +1)*DO_QUERY_ALLOC_NUM*sizeof(char *)); - if (!res->data) - { - pool_error("do_query: malloc failed"); - return POOL_ERROR; - } } } } diff --git a/src/streaming_replication/pool_worker_child.c b/src/streaming_replication/pool_worker_child.c index e17255ac7..160c7585a 100644 --- a/src/streaming_replication/pool_worker_child.c +++ b/src/streaming_replication/pool_worker_child.c @@ -77,7 +77,6 @@ static long text_to_lsn(char *text); static RETSIGTYPE my_signal_handler(int sig); static RETSIGTYPE reload_config_handler(int sig); static void reload_config(void); -static void clean_persistent_connection_error_callback(void *arg); #define CHECK_REQUEST \ do { \ if (reload_config_request) \ @@ -161,21 +160,21 @@ void do_worker_child(void) if (pool_config->sr_check_period > 0 && MASTER_SLAVE && !strcmp(pool_config->master_slave_sub_mode, MODE_STREAMREP)) { - ErrorContextCallback errcallback; - /* Check and establish persistent connections to the backend */ establish_persistent_connection(); + PG_TRY(); + { - errcallback.callback = clean_persistent_connection_error_callback; - errcallback.arg = NULL; - errcallback.previous = error_context_stack; - error_context_stack = &errcallback; - - /* Do replication time lag checking */ - check_replication_time_lag(); + /* Do replication time lag checking */ + check_replication_time_lag(); + } + PG_CATCH(); + { + discard_persistent_connection(); + sleep(pool_config->sr_check_period); + PG_RE_THROW(); + } + PG_END_TRY(); - /* Pop the error context stack */ - error_context_stack = errcallback.previous; - /* Discard persistent connections */ discard_persistent_connection(); } @@ -219,6 +218,10 @@ static void establish_persistent_connection(void) } PG_CATCH(); { + ErrorData *edata; + edata = CopyErrorData(); + printf("%s",edata->message); + FlushErrorState(); slots[i] = NULL; } PG_END_TRY(); diff --git a/src/system_db/pool_system.c b/src/system_db/pool_system.c index 82f01c529..55bf63b54 100644 --- a/src/system_db/pool_system.c +++ b/src/system_db/pool_system.c @@ -700,31 +700,33 @@ system_db_health_check(void) if (fd < 0) { - pool_error("health check failed. SystemDB host %s at port %d is down", - SYSDB_INFO->hostname, - SYSDB_INFO->port); - - return -1; + ereport(ERROR, + (errmsg("SystemDB health check failed"), + errdetail("DB host \"%s\" at port %d is down", + SYSDB_INFO->hostname, + SYSDB_INFO->port))); } if (write(fd, &mysp, sizeof(mysp)) < 0) { - pool_error("health check failed during write. SystemDB host %s at port %d is down", - SYSDB_INFO->hostname, - SYSDB_INFO->port); close(fd); - return -1; + ereport(ERROR, + (errmsg("SystemDB health check failed"), + errdetail("Write failed on DB host \"%s\" at port %d is down", + SYSDB_INFO->hostname, + SYSDB_INFO->port))); } read(fd, &kind, 1); if (write(fd, "X", 1) < 0) { - pool_error("health check failed during write. SystemDB host %s at port %d is down", - SYSDB_INFO->hostname, - SYSDB_INFO->port); close(fd); - return -1; + ereport(ERROR, + (errmsg("SystemDB health check failed"), + errdetail("Write failed on DB host \"%s\" at port %d is down", + SYSDB_INFO->hostname, + SYSDB_INFO->port))); } close(fd); [parent: 711b00a8ff7d]