Act nowcan affect a running systemThe payload contains two non-merge commits and their merge. No superseded_by metadata is present. The test-only follow-up changes logging around expected failures and does not alter runtime code.
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.
2 of 2 entries · 3 commits upstream
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.
Upgrade recommended
Upgrade to the merged build 2.4.17677 and add a regression test that forces Commit to fail on each SQLite3 or Zeos connection path your service uses.
Public API
TSqlDBConnectionProperties.SharedTransactionbehaviour-changed — A failed commit now releases its transaction ownership and rolls back when no other counted owner remains.
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.