mORMot2 DailyDaily read of upstream commits

Failed shared commits now release their database transaction

A failed SharedTransaction commit could unregister its owner while leaving the underlying SQLite3 or Zeos transaction open. Later statements on the pooled connection would then run inside that abandoned transaction, and disconnect could raise another error. Delphi and FPC services using external SQL shared transactions should take the fix and exercise their commit-failure paths.

TL;DR

  • TSqlDBConnectionProperties.SharedTransaction now rolls back its own database transaction after a failed commit, or releases only its nesting level when another owner remains.
  • SQLite3 and Zeos StartTransaction restore TransactionCount when the underlying database call fails.
  • The regression test covers deferred-foreign-key commit failures, nested transaction ownership and both exception modes without polluting test logs.
  • Land on the merged revision at build 2.4.17677; the raw payload lists no later superseding fix.

Upgrade advice

Land on 7d6480007c2bb756e51a67342f947ac6c977eeb0 at build 2.4.17677. Teams using TSqlDBConnectionProperties.SharedTransaction with SQLite3 or Zeos should upgrade and test failed commits, especially deferred constraints and dropped connections. No migration is required, and the raw payload lists no superseded_by successor.

Commits3
Lines+275 -47
Read1 min

2 of 2 entries · 3 commits upstream

# Entry Category Units
1 High A failed shared commit no longer leaves its pooled connection inside a transaction mormot.db.sql adds TSqlDBConnectionProperties.ReleaseFailedCommit and invokes it when SharedTransaction fails during transCommitWithException or transCommitWithoutException. It rolls back when the failed shared transaction is the sole counted owner, but only decrements fTransactionCount when another nested owner remains. mormot.db.sql.sqlite3 and mormot.db.sql.zeos also undo the inherited TransactionCount increment if their actual StartTransaction call raises. Fixes mormot.db.sql+3 ff3b6073+117-9

db: release the connection transaction when SharedTransaction() Commit fails

Impact

Before this fix, a commit failure such as a deferred SQLite3 foreign-key violation or lost Zeos connection could leave the physical transaction open after its shared entry was removed. Later Delphi or FPC requests reusing that connection could execute inside the abandoned transaction, and disconnect could fail. The corrected path cleans up its ownership without closing a transaction that belongs to a nested caller.

Public API

  • TSqlDBConnectionProperties.SharedTransactionbehaviour-changed — A failed commit now releases its transaction ownership and rolls back when no other counted owner remains.

Dimitris Kounalakis · 10:06 UTC · view the commit on GitHub →

2 Low Expected commit failures no longer fill the regression-test log TTestExternalDatabase.SharedTransactionCommitFailure now sets TSynLog.Family.ExceptionIgnoreCurrentThread while it deliberately triggers invalid deferred-foreign-key commits, then restores the flag in a finally block. The assertions for rollback, TransactionCount, nested ownership, propagated exceptions and subsequent transaction reuse are unchanged. Tests test.orm.extdb 1b585fcd+35-29

test: no exception logging for the expected COMMIT failures

Impact

Application and library runtime behaviour is unchanged. Automated Delphi and FPC test output is quieter while the same failed-commit cleanup cases remain covered.

Dimitris Kounalakis · 17:28 UTC · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits1007
Active days49/60
Busiest2026-09-30
Peak60
2026-09-30: 60 commits2026-10-01: 26 commits2026-10-02: 30 commits2026-10-03: 32 commits2026-10-04: 15 commits2026-10-05: 1 commit2026-10-06: 26 commits2026-10-07: 37 commits2026-10-08: 27 commits2026-10-09: 35 commits2026-10-10: 12 commits2026-10-11: 2 commits2026-10-12: 40 commits2026-10-13: 31 commits2026-10-14: 23 commits2026-10-15: 16 commits2026-10-16: 27 commits2026-10-17: 0 commits2026-10-18: 0 commits2026-10-19: 0 commits2026-10-20: 0 commits2026-10-21: 0 commits2026-10-22: 3 commits2026-10-23: 6 commits2026-10-24: 29 commits2026-10-25: 7 commits2026-10-26: 25 commits2026-10-27: 4 commits2026-10-28: 8 commits2026-10-29: 17 commits2026-10-30: 20 commits2026-10-31: 0 commits2026-11-01: 0 commits2026-11-02: 16 commits2026-11-03: 32 commits2026-11-04: 15 commits2026-11-05: 32 commits2026-11-06: 26 commits2026-11-07: 19 commits2026-11-08: 2 commits2026-11-09: 29 commits2026-11-10: 17 commits2026-11-11: 8 commits2026-11-12: 38 commits2026-11-13: 39 commits2026-11-14: 9 commits2026-11-15: 6 commits2026-11-16: 21 commits2026-11-17: 30 commits2026-11-18: 37 commits2026-11-19: 28 commits2026-11-20: 31 commits2026-11-21: 0 commits2026-11-22: 0 commits2026-11-23: 1 commit2026-11-24: 6 commits2026-11-25: 3 commits2026-11-26: 3 commits2026-11-27: 0 commits2026-11-28: 0 commits
2026-09-302026-11-28