--- a/src/server/plugins/postgresql/resource.c Sat Jan 22 19:13:40 2022 +0100 +++ b/src/server/plugins/postgresql/resource.c Tue Jan 25 17:45:56 2022 +0100 @@ -51,10 +51,10 @@ // test connection PGconn *test_connection = PQconnectdb(connection); - if(pg_check_connection(rpname, test_connection)) { - return NULL; // error, pg_check_connection does the logging + if(pg_check_connection(LOG_WARN, rpname, test_connection)) { + log_ereport(LOG_WARN, "Resource pool %s: Connection check failed", rpname); } - PQfinish(test_connection); + if(test_connection) PQfinish(test_connection); PgResourcePool *pg = pool_malloc(pool, sizeof(PgResourcePool)); if(!pg) { @@ -68,9 +68,9 @@ } -int pg_check_connection(const char *rpname, PGconn *connection) { +int pg_check_connection(int loglevel, const char *rpname, PGconn *connection) { if(!connection) { - log_ereport(LOG_FAILURE, "Resource pool %s: Cannot create PQ connection", rpname); + log_ereport(loglevel, "Resource pool %s: Cannot create PQ connection", rpname); return 1; } if(PQstatus(connection) != CONNECTION_OK) { @@ -82,7 +82,7 @@ errlen--; } } - log_ereport(LOG_FAILURE, "Resource pool %s: Failed to connect to database: %.*s", rpname, errlen, err); + log_ereport(loglevel, "Resource pool %s: Failed to connect to database: %.*s", rpname, errlen, err); PQfinish(connection); return 1; } @@ -96,7 +96,7 @@ void * pg_resourcepool_createresource(PgResourcePool *pg) { PGconn *connection = PQconnectdb(pg->connection); - if(pg_check_connection(pg->name, connection)) { + if(pg_check_connection(LOG_FAILURE, pg->name, connection)) { return NULL; }