summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-04-07 11:24:16 +0200
committerChristian Grothoff <christian@grothoff.org>2017-04-07 11:24:16 +0200
commita2d89f2803128a19f87cf1ad55b1c72a173e812e (patch)
treec2e1cf052f39ecdca282064271921b5477d52cec
parent930101256eed811b7c7b76b7cb7e8c6f797b03f7 (diff)
downloadexchange-a2d89f2803128a19f87cf1ad55b1c72a173e812e.tar.gz
exchange-a2d89f2803128a19f87cf1ad55b1c72a173e812e.tar.bz2
exchange-a2d89f2803128a19f87cf1ad55b1c72a173e812e.zip
even more logging on DB issues
-rw-r--r--src/exchange/taler-exchange-httpd_db.c4
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c36
2 files changed, 25 insertions, 15 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 9e345e806..191e2a4b6 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -593,7 +593,7 @@ TEH_DB_execute_refund (struct MHD_Connection *connection,
return TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_REFUND_STORE_DB_ERROR);
}
- COMMIT_TRANSACTION(session, connection);
+ COMMIT_TRANSACTION (session, connection);
return TEH_RESPONSE_reply_refund_success (connection,
refund);
@@ -622,9 +622,11 @@ TEH_DB_execute_reserve_status (struct MHD_Connection *connection,
return TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_DB_SETUP_FAILED);
}
+ START_TRANSACTION (session, connection);
rh = TEH_plugin->get_reserve_history (TEH_plugin->cls,
session,
reserve_pub);
+ COMMIT_TRANSACTION (session, connection);
if (NULL == rh)
return TEH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_NOT_FOUND,
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index d2a2bba66..f85954031 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -34,9 +34,17 @@
* Log a query error.
*
* @param result PQ result object of the query that failed
+ * @param conn SQL connection that was used
*/
-#define QUERY_ERR(result) \
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Query failed at %s:%u: %s (%s)\n", __FILE__, __LINE__, PQresultErrorMessage (result), PQresStatus (PQresultStatus (result)))
+#define QUERY_ERR(result,conn) \
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
+ "Query failed at %s:%u: %s/%s/%s/%s/%s\n", \
+ __FILE__, __LINE__, \
+ PQresultErrorField (result, PG_DIAG_MESSAGE_PRIMARY), \
+ PQresultErrorField (result, PG_DIAG_MESSAGE_DETAIL), \
+ PQresultErrorMessage (result), \
+ PQresStatus (PQresultStatus (result)), \
+ PQerrorMessage(conn));
/**
@@ -1755,7 +1763,7 @@ postgres_get_denomination_info (void *cls,
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
return GNUNET_SYSERR;
}
@@ -1846,7 +1854,7 @@ postgres_reserve_get (void *cls,
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
return GNUNET_SYSERR;
}
@@ -1906,7 +1914,7 @@ reserves_update (void *cls,
params);
if (PGRES_COMMAND_OK != PQresultStatus(result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
ret = GNUNET_SYSERR;
}
else
@@ -1987,7 +1995,7 @@ postgres_reserves_in_insert (void *cls,
params);
if (PGRES_COMMAND_OK != PQresultStatus(result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
goto rollback;
}
@@ -2031,7 +2039,7 @@ postgres_reserves_in_insert (void *cls,
session);
return GNUNET_NO;
}
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
goto rollback;
}
@@ -2116,7 +2124,7 @@ postgres_get_withdraw_info (void *cls,
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
goto cleanup;
}
if (0 == PQntuples (result))
@@ -2197,7 +2205,7 @@ postgres_insert_withdraw_info (void *cls,
params);
if (PGRES_COMMAND_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
return GNUNET_SYSERR;
}
@@ -2277,7 +2285,7 @@ postgres_get_reserve_history (void *cls,
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
goto cleanup;
}
if (0 == (rows = PQntuples (result)))
@@ -2343,7 +2351,7 @@ postgres_get_reserve_history (void *cls,
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
goto cleanup;
}
@@ -2402,7 +2410,7 @@ postgres_get_reserve_history (void *cls,
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
goto cleanup;
}
rows = PQntuples (result);
@@ -3979,7 +3987,7 @@ postgres_get_coin_transactions (void *cls,
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
goto cleanup;
}
@@ -4836,7 +4844,7 @@ postgres_wire_prepare_data_get (void *cls,
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
- QUERY_ERR (result);
+ QUERY_ERR (result, session->conn);
PQclear (result);
return GNUNET_SYSERR;
}