postgresql plugin: Restart a writer transaction if the writer's query failed.
authorSebastian Harl <sh@tokkee.org>
Wed, 14 Nov 2012 19:05:33 +0000 (20:05 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 14 Nov 2012 19:05:33 +0000 (20:05 +0100)
The failed query inside the transaction causes the transaction to be aborted
and all subsequent queries to fail as well.

src/postgresql.c

index 9b264d9..8a9fa10 100644 (file)
@@ -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;
                }