summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_db.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/taler-exchange-httpd_db.c')
-rw-r--r--src/exchange/taler-exchange-httpd_db.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 71f82e9d5..abbb6c3fe 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -228,6 +228,8 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
struct TEH_KS_StateHandle *mks;
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
int ret;
+ enum GNUNET_DB_QueryStatus qs;
+ unsigned int retries = 0;
if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls)))
{
@@ -235,6 +237,7 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
return TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_DB_SETUP_FAILED);
}
+ again:
if (GNUNET_YES ==
TEH_plugin->have_deposit (TEH_plugin->cls,
session,
@@ -305,10 +308,10 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
}
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tl);
- if (GNUNET_OK !=
- TEH_plugin->insert_deposit (TEH_plugin->cls,
- session,
- deposit))
+ qs = TEH_plugin->insert_deposit (TEH_plugin->cls,
+ session,
+ deposit);
+ if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
TALER_LOG_WARNING ("Failed to store /deposit information in database\n");
TEH_plugin->rollback (TEH_plugin->cls,
@@ -316,6 +319,16 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection,
return TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_DEPOSIT_STORE_DB_ERROR);
}
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ {
+ retries++;
+ TEH_plugin->rollback (TEH_plugin->cls,
+ session);
+ if (retries > 5)
+ return TEH_RESPONSE_reply_internal_db_error (connection,
+ TALER_EC_DEPOSIT_STORE_DB_ERROR);
+ goto again;
+ }
COMMIT_TRANSACTION(session, connection);
GNUNET_assert (GNUNET_SYSERR !=