commit 41b3950cde9ea9a6fe7e0d5c668c7a768b3b6ad4 parent 1d9fa76053c5523de38c1cf58f3887ed33fae4dc Author: Christian Grothoff <christian@grothoff.org> Date: Fri, 7 Aug 2026 00:16:11 +0200 defensive patch: do not rely on serializability on issuing recepts Diffstat:
| M | src/donaudb/do_insert_receipt_issued.sql | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/donaudb/do_insert_receipt_issued.sql b/src/donaudb/do_insert_receipt_issued.sql @@ -45,7 +45,12 @@ BEGIN ,max_per_year.frac ,my_year FROM charities chari - WHERE charity_id=in_charity_id; + WHERE charity_id=in_charity_id + -- The annual limit is a read-decide-write on this row. Take the row + -- lock here so that the decision is atomic at ANY isolation level; do + -- not rely on the session default being SERIALIZABLE (that default is + -- installed best-effort and DONAUDB_start_read_committed() exists). + FOR UPDATE OF chari; IF (my_year > in_year) THEN