From e14c0448fb1afe92cba0716b9f6bd8e1805d16fe Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 8 Mar 2012 22:07:23 +0100 Subject: [PATCH] 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. --- src/postgresql.c | 6 ++++++ 1 file changed, 6 insertions(+) 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", -- 2.11.0