fix: dispatch guard and Defect-safe rollback (#32)
A readable intent that fails in handling now always gets exactly one ack: the new static internal code, unless the handler's own ack was already enqueued. Both transaction helpers roll back on every unwind path, Defect included, so the shared SQLite connection never keeps an open transaction. Test-only dispfault build covers catchable/defect/after-ack; DESIGN 6.5 records internal as an owner decision and 6.2 names refusal codes as additive.
This commit is contained in:
+8
-3
@@ -432,12 +432,17 @@ template authoringTransaction*(db: DbConn, body: untyped) =
|
||||
db.exec(sql"PRAGMA synchronous=FULL")
|
||||
try:
|
||||
db.exec(sql"BEGIN")
|
||||
var open = true
|
||||
try:
|
||||
body
|
||||
db.exec(sql"COMMIT")
|
||||
except CatchableError:
|
||||
try: db.exec(sql"ROLLBACK")
|
||||
except CatchableError: discard
|
||||
open = false
|
||||
except Exception:
|
||||
# #32: roll back on every unwind path, `Defect` included, or the shared connection keeps an
|
||||
# authoring transaction open for the next caller.
|
||||
if open:
|
||||
try: db.exec(sql"ROLLBACK")
|
||||
except Exception: discard
|
||||
raise
|
||||
finally:
|
||||
db.exec(sql"PRAGMA synchronous=NORMAL")
|
||||
|
||||
Reference in New Issue
Block a user