Repository navigation
Transaction recovers a dead transaction on entry
Transaction.__aenter__ now rolls back the session's transaction before joining it when that transaction can no longer continue. That covers two cases: SQLAlchemy marked it inactive after a failed flush, or a connection it already holds is invalidated. Before, a connection lost on a query or flush after the block made the retried attempt fail with PendingRollbackError. Now the retry starts on a fresh connection (#74).
A live transaction is still joined, so a caller's uncommitted work is never discarded.
Upgrade notes
- Keep every query a retried coroutine runs inside its
Transactionblock. A query before the block runs ahead of__aenter__on the retried attempt and still fails it. So does a serialization failure outside the block, because it aborts the transaction without losing the connection. - The check reads SQLAlchemy's private
SessionTransaction._connections, because there is no public accessor yet (sqlalchemy/sqlalchemy#13684). If a future SQLAlchemy release renames it, entering falls back to the 0.8.0 behaviour.
What's Changed
- docs: link projects that use the Transaction use-case shape by @lesnik512 in #73
- fix: Transaction rolls back a dead transaction before joining it by @lesnik512 in #75
Full Changelog: 0.8.0...0.8.1