From: Sebastian Harl Date: Wed, 14 Nov 2012 19:05:33 +0000 (+0100) Subject: postgresql plugin: Restart a writer transaction if the writer's query failed. X-Git-Tag: collectd-5.2.0~13^2~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f1afdb3de66275f48ca99ec57dafe4ac8b52bf97;p=collectd.git postgresql plugin: Restart a writer transaction if the writer's query failed. The failed query inside the transaction causes the transaction to be aborted and all subsequent queries to fail as well. --- diff --git a/src/postgresql.c b/src/postgresql.c index 9b264d9e..8a9fa101 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -886,6 +886,12 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl, writer->statement, params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7]); + + /* this will abort any current transaction -> restart */ + if (db->commit_interval > 0) + if (c_psql_commit (db) == 0) + c_psql_begin (db); + pthread_mutex_unlock (&db->db_lock); return -1; }