commit cdd6dacd6d1efb6cd6ceb0d51fbca0969ddd68ca
parent b93eb9114b5c36039a2dcbfacf1f598545bab6d1
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 13 Aug 2026 21:35:01 +0200
another commit correction
Diffstat:
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/src/auditordb/start.c b/src/auditordb/start.c
@@ -71,11 +71,34 @@ TALER_AUDITORDB_commit (struct TALER_AUDITORDB_PostgresContext *pg)
GNUNET_PQ_query_param_end
};
+ enum GNUNET_DB_QueryStatus qs;
+ PGresult *result;
+
PREPARE (pg,
- "start",
+ "commit",
"COMMIT");
+ result = GNUNET_PQ_exec_prepared (pg->conn,
+ "commit",
+ params);
+ qs = GNUNET_PQ_eval_result (pg->conn,
+ "commit",
+ result);
+ if ( (0 <= qs) &&
+ (NULL != result) &&
+ (0 == strcmp ("ROLLBACK",
+ PQcmdStatus (result))) )
+ {
+ /* Postgres accepts COMMIT on an already-aborted transaction and
+ answers PGRES_COMMAND_OK with the command tag ROLLBACK, which is
+ otherwise indistinguishable from a successful commit. Report it
+ as a soft error so the caller retries instead of checkpointing
+ progress for writes that are gone. */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Transaction `%s' was rolled back by the database\n",
+ pg->transaction_name);
+ qs = GNUNET_DB_STATUS_SOFT_ERROR;
+ }
+ PQclear (result);
pg->transaction_name = NULL;
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "start",
- params);
+ return qs;
}