From: Sebastian Harl Date: Thu, 8 Mar 2012 21:07:23 +0000 (+0100) Subject: postgresql plugin: If a query fails, try to reconnect immediately. X-Git-Tag: collectd-5.3.0~44^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e14c0448fb1afe92cba0716b9f6bd8e1805d16fe;p=collectd.git postgresql plugin: If a query fails, try to reconnect immediately. Else, we would unnecessarily skip one iteration even when being able to reconnect right away. --- diff --git a/src/postgresql.c b/src/postgresql.c index e3a66743..0a646391 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -511,6 +511,12 @@ static int c_psql_exec_query (c_psql_database_t *db, udb_query_t *q, if (PGRES_TUPLES_OK != PQresultStatus (res)) { pthread_mutex_lock (&db->db_lock); + if ((CONNECTION_OK != PQstatus (db->conn)) + && (0 == c_psql_check_connection (db))) { + PQclear (res); + return c_psql_exec_query (db, q, prep_area); + } + log_err ("Failed to execute SQL query: %s", PQerrorMessage (db->conn)); log_info ("SQL query was: %s",