View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012211 | Taler | sync | public | 2026-11-18 16:41 | 2026-11-18 16:42 |
| Reporter | bot-cg [agent] | ||||
| Implementer | avalos | ||||
| Priority | normal | Severity | minor | ||
| Status | implementing | ||||
| Product Version | git (master) | ||||
| Summary | 0012211: sync-httpd2 reconcile asserts that two separate database passes return the same number of blocks | ||||
| Description | SH_backup_blocks_reconcile_get() (src/sync/sync-httpd2_get-backups-KEY-blocks-reconcile.c) first counts the account's blocks with SYNCDB_lookup_block_hashes_TR() and sizes the filter from that, then calls it again to hash the blocks into the filter, each as its own statement. It then does GNUNET_assert (qs == total_blocks) and GNUNET_assert (rhc.count == total_blocks). Another sync-httpd2 process on the same database, or sync-dbinit -g collecting garbage, can change the block set between the two passes, and the assert takes the whole daemon down. SYNCDB_lookup_block_hashes_TR() also ignores an extraction error of a row (hic.qs) and returns a partial count. Confirmed by reading the code at 9f3dac2; the race was not reproduced. The attached patch reports the number of blocks actually hashed into the filter instead of asserting, and returns the extraction error from the database function. | ||||
| Additional Information | Recorded as SYNC-010 in sync's review notes; the patch is that review's 0005 (in 303a031 on dev/bots/review), unchanged. | ||||
| Tags | No tags attached. | ||||
| Attached Files | 12211-sync-do-not-assert-that-two-reconcile-passes-see-the.patch (2,127 bytes)
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Wed, 18 Nov 2026 17:41:26 +0100
Subject: [PATCH] sync: do not assert that two reconcile passes see the same
blocks
The counting pass and the hashing pass are separate transactions, so the
block set can change in between.
Issue: https://bugs.taler.net/n/12211
Assisted by LLM
---
src/sync/sync-httpd2_get-backups-KEY-blocks-reconcile.c | 8 ++++++--
src/syncdb/syncdb_lookup_block_hashes_TR.c | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/sync/sync-httpd2_get-backups-KEY-blocks-reconcile.c b/src/sync/sync-httpd2_get-backups-KEY-blocks-reconcile.c
index 65c7868..f440d38 100644
--- a/src/sync/sync-httpd2_get-backups-KEY-blocks-reconcile.c
+++ b/src/sync/sync-httpd2_get-backups-KEY-blocks-reconcile.c
@@ -210,8 +210,12 @@ SH_backup_blocks_reconcile_get (struct MHD_Request *request,
TALER_EC_GENERIC_DB_FETCH_FAILED,
NULL);
}
- GNUNET_assert (qs == (enum SYNC_DB_QueryStatus) total_blocks);
- GNUNET_assert (rhc.count == total_blocks);
+ /* The two passes are separate transactions: another daemon
+ process or the garbage collector may have changed the block set
+ in between. The filter was sized from the first count; report
+ what was actually hashed into it. */
+ GNUNET_break (qs == (enum SYNC_DB_QueryStatus) rhc.count);
+ total_blocks = rhc.count;
}
/* Serialize (network byte order) and base32-encode. */
diff --git a/src/syncdb/syncdb_lookup_block_hashes_TR.c b/src/syncdb/syncdb_lookup_block_hashes_TR.c
index 93566d4..693f40b 100644
--- a/src/syncdb/syncdb_lookup_block_hashes_TR.c
+++ b/src/syncdb/syncdb_lookup_block_hashes_TR.c
@@ -164,6 +164,9 @@ SYNCDB_lookup_block_hashes_TR (
default:
break;
}
+ /* a row that could not be extracted must not yield a partial count */
+ if (hic.qs < 0)
+ return hic.qs;
/* map the flags of the (single) status row to SYNC_DB codes */
if (hic.out_account_missing)
return SYNC_DB_PAYMENT_REQUIRED;
--
2.47.3
| ||||
| child of | 0012186 | new | Unchecked array lengths and counts in exchange, merchant and anastasis: review after 2a57cbcaf [meta] |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-11-18 16:41 | bot-cg | New Issue | |
| 2026-11-18 16:41 | bot-cg | Relationship added | child of 0012186 |
| 2026-11-18 16:41 | bot-cg | Implementer | => avalos |
| 2026-11-18 16:41 | bot-cg | Release signed by | => Florian Dold |
| 2026-11-18 16:41 | bot-cg | Deployed by | => avalos |
| 2026-11-18 16:41 | bot-cg | Verifier | => avalos |
| 2026-11-18 16:41 | bot-cg | Communicator | => CM_7 |
| 2026-11-18 16:41 | bot-cg | File Added: 12211-sync-do-not-assert-that-two-reconcile-passes-see-the.patch | |
| 2026-11-18 16:42 | Christian Grothoff | Status | new => implementing |