[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: Preflight checks:
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: Preflight checks: |
Date: |
Wed, 15 Jan 2020 12:36:19 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new e77ccd03 Preflight checks:
e77ccd03 is described below
commit e77ccd03906bd2db068136bb383976f714b3289e
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Jan 15 12:34:54 2020 +0100
Preflight checks:
put preflight check inside exchangedb start()
function, and provide a preflight method for
auditordb.
---
src/auditor/taler-auditor-httpd.c | 4 +--
src/auditor/taler-auditor-httpd_db.c | 1 -
src/auditordb/plugin_auditordb_postgres.c | 41 +++++++++++++++++++++++++++++
src/exchangedb/plugin_exchangedb_postgres.c | 18 +++++++++++--
4 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/src/auditor/taler-auditor-httpd.c
b/src/auditor/taler-auditor-httpd.c
index 55a34377..0acd8d8b 100644
--- a/src/auditor/taler-auditor-httpd.c
+++ b/src/auditor/taler-auditor-httpd.c
@@ -372,8 +372,8 @@ handle_mhd_request (void *cls,
{ "/version", MHD_HTTP_METHOD_GET, "application/json",
NULL, 0,
&handle_version, MHD_HTTP_OK },
- /* Landing page, for now tells humans to go away (FIXME: replace
- with auditor's welcome page!) */
+ /* Landing page, for now tells humans to go away
+ * (NOTE: ideally, the reverse proxy will respond with a nicer page) */
{ "/", MHD_HTTP_METHOD_GET, "text/plain",
"Hello, I'm the Taler auditor. This HTTP server is not for humans.\n", 0,
&TAH_MHD_handler_static_response, MHD_HTTP_OK },
diff --git a/src/auditor/taler-auditor-httpd_db.c
b/src/auditor/taler-auditor-httpd_db.c
index 3433e9a9..ba40ff80 100644
--- a/src/auditor/taler-auditor-httpd_db.c
+++ b/src/auditor/taler-auditor-httpd_db.c
@@ -70,7 +70,6 @@ TAH_DB_run_transaction (struct MHD_Connection *connection,
"failed to establish session with
database");
return GNUNET_SYSERR;
}
- // TAH_plugin->preflight (TAH_plugin->cls, session); // FIXME: needed?
for (unsigned int retries = 0; retries < MAX_TRANSACTION_COMMIT_RETRIES;
retries++)
{
diff --git a/src/auditordb/plugin_auditordb_postgres.c
b/src/auditordb/plugin_auditordb_postgres.c
index 7360258a..0d16011f 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -62,6 +62,8 @@ struct TALER_AUDITORDB_Session
* Postgres connection handle.
*/
struct GNUNET_PQ_Context *conn;
+
+ const char *transaction_name;
};
@@ -1012,6 +1014,43 @@ postgres_get_session (void *cls)
return session;
}
+/**
+ * Do a pre-flight check that we are not in an uncommitted transaction.
+ * If we are, try to commit the previous transaction and output a warning.
+ * Does not return anything, as we will continue regardless of the outcome.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param session the database connection
+ */
+static void
+postgres_preflight (void *cls,
+ struct TALER_AUDITORDB_Session *session)
+{
+ struct GNUNET_PQ_ExecuteStatement es[] = {
+ GNUNET_PQ_make_execute ("ROLLBACK"),
+ GNUNET_PQ_EXECUTE_STATEMENT_END
+ };
+
+ (void) cls;
+ if (NULL == session->transaction_name)
+ return; /* all good */
+ if (GNUNET_OK ==
+ GNUNET_PQ_exec_statements (session->conn,
+ es))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "BUG: Preflight check committed transaction `%s'!\n",
+ session->transaction_name);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "BUG: Preflight check failed to commit transaction `%s'!\n",
+ session->transaction_name);
+ }
+ session->transaction_name = NULL;
+}
+
/**
* Start a transaction.
@@ -1029,6 +1068,8 @@ postgres_start (void *cls,
GNUNET_PQ_EXECUTE_STATEMENT_END
};
+ postgres_preflight (cls,
+ session);
(void) cls;
if (GNUNET_OK !=
GNUNET_PQ_exec_statements (session->conn,
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c
b/src/exchangedb/plugin_exchangedb_postgres.c
index e4caec2d..a657b405 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -78,7 +78,7 @@
/**
- * Handle for a database session (per-thread, for transactions).
+ * Handler for a database session (per-thread, for transactions).
*/
struct TALER_EXCHANGEDB_Session
{
@@ -1711,6 +1711,17 @@ postgres_get_session (void *cls)
return session;
}
+/**
+ * Do a pre-flight check that we are not in an uncommitted transaction.
+ * If we are, try to commit the previous transaction and output a warning.
+ * Does not return anything, as we will continue regardless of the outcome.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param session the database connection
+ */
+static void
+postgres_preflight (void *cls,
+ struct TALER_EXCHANGEDB_Session *session);
/**
* Start a transaction.
@@ -1731,6 +1742,9 @@ postgres_start (void *cls,
GNUNET_PQ_EXECUTE_STATEMENT_END
};
+ postgres_preflight (cls,
+ session);
+
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting transaction on %p\n",
@@ -1813,7 +1827,7 @@ postgres_preflight (void *cls,
struct TALER_EXCHANGEDB_Session *session)
{
struct GNUNET_PQ_ExecuteStatement es[] = {
- GNUNET_PQ_make_execute ("COMMIT"),
+ GNUNET_PQ_make_execute ("ROLLBACK"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: Preflight checks:,
gnunet <=