commit 964723bcd660682afee95b53247debd6e0e9f495
parent 5f6d203e072e430f5db0956ee42ef5f460ccc5dc
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 1 Aug 2026 00:46:04 +0200
fix non-terminating taler-exchange-aggregator -t
Diffstat:
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/exchangedb/get_ready_deposit.c b/src/exchangedb/get_ready_deposit.c
@@ -34,8 +34,16 @@ TALER_EXCHANGEDB_get_ready_deposit (struct TALER_EXCHANGEDB_PostgresContext *pg,
{
struct GNUNET_TIME_Absolute now
= GNUNET_TIME_absolute_get ();
+ /* Must match the cut-off used by TALER_EXCHANGEDB_do_aggregate()
+ exactly: a deposit whose refund deadline has not passed by that
+ cut-off cannot be aggregated yet, so reporting it as "ready"
+ would make the aggregator spin on it without making progress. */
+ struct GNUNET_TIME_Absolute refund_cutoff
+ = GNUNET_TIME_absolute_round_down (now,
+ pg->aggregator_shift);
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_absolute_time (&refund_cutoff),
GNUNET_PQ_query_param_uint64 (&start_shard_row),
GNUNET_PQ_query_param_uint64 (&end_shard_row),
GNUNET_PQ_query_param_end
@@ -65,8 +73,9 @@ TALER_EXCHANGEDB_get_ready_deposit (struct TALER_EXCHANGEDB_PostgresContext *pg,
" USING (wire_target_h_payto)"
" WHERE NOT (bdep.done OR bdep.policy_blocked)"
" AND bdep.wire_deadline<=$1"
- " AND bdep.shard >= $2"
- " AND bdep.shard <= $3"
+ " AND bdep.refund_deadline<$2" /* see do_aggregate.c */
+ " AND bdep.shard >= $3"
+ " AND bdep.shard <= $4"
" ORDER BY "
" bdep.wire_deadline ASC"
" ,bdep.shard ASC"
diff --git a/src/include/exchange-database/get_ready_deposit.h b/src/include/exchange-database/get_ready_deposit.h
@@ -28,8 +28,18 @@
/**
* Obtain information about deposits that are ready to be executed. Such
- * deposits must not be marked as "done", the execution time must be
- * in the past, and the KYC status must be 'ok'.
+ * deposits must not be marked as "done" or policy-blocked, their wire
+ * deadline must have passed, and their refund deadline must have passed
+ * the current aggregation shift boundary.
+ *
+ * The last condition is what makes the result *actionable*: it is the
+ * same cut-off that TALER_EXCHANGEDB_do_aggregate() applies when marking
+ * deposits as done. Without it this function reports deposits that the
+ * aggregator then cannot make progress on, which makes it spin (and
+ * `taler-exchange-aggregator -t` never reach an idle shard, hence never
+ * terminate). Note that a deposit is therefore not necessarily ready
+ * the instant its wire deadline passes; it becomes ready at the next
+ * shift boundary, which is precisely what AGGREGATOR_SHIFT asks for.
*
* @param pg the database context
* @param start_shard_row minimum shard row to select