aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/plugin_exchangedb_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-04-14 00:00:50 +0200
committerChristian Grothoff <christian@grothoff.org>2022-04-14 00:00:50 +0200
commita13f90a15ee910c0ada316366e197de11bc6cc62 (patch)
tree2e4b400aa740782f65918eff487949409205f1bd /src/exchangedb/plugin_exchangedb_postgres.c
parent5882e6b56bd64296761ba10d1192499808e5c594 (diff)
downloadexchange-a13f90a15ee910c0ada316366e197de11bc6cc62.tar.xz
add wirewatch shutdown shard cleanup logic
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 9d3171c2e..ff2dcbf42 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3354,6 +3354,15 @@ prepare_statements (struct PostgresClosure *pg)
" ORDER BY end_row DESC"
" LIMIT 1;",
1),
+ /* Used in #postgres_abort_shard() */
+ GNUNET_PQ_make_prepare (
+ "abort_shard",
+ "UPDATE work_shards"
+ " SET last_attempt=0"
+ " WHERE job_name = $1 "
+ " AND start_row = $2 "
+ " AND end_row = $3;",
+ 3),
/* Used in #postgres_begin_shard() */
GNUNET_PQ_make_prepare (
"claim_next_shard",
@@ -12587,6 +12596,35 @@ commit:
/**
+ * Function called to abort work on a shard.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param job_name name of the operation to abort a word shard for
+ * @param start_row inclusive start row of the shard
+ * @param end_row exclusive end row of the shard
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_abort_shard (void *cls,
+ const char *job_name,
+ uint64_t start_row,
+ uint64_t end_row)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (job_name),
+ GNUNET_PQ_query_param_uint64 (&start_row),
+ GNUNET_PQ_query_param_uint64 (&end_row),
+ GNUNET_PQ_query_param_end
+ };
+
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "abort_shard",
+ params);
+}
+
+
+/**
* Function called to persist that work on a shard was completed.
*
* @param cls the @e cls of this struct with the plugin-specific state
@@ -13889,6 +13927,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &postgres_insert_records_by_table;
plugin->begin_shard
= &postgres_begin_shard;
+ plugin->abort_shard
+ = &postgres_abort_shard;
plugin->complete_shard
= &postgres_complete_shard;
plugin->begin_revolving_shard