Skip to content

0.8.1

Latest

Choose a tag to compare

@github-actions github-actions released this 17 Oct 07:45
· 3 commits to main since this release
0.8.1
af93268

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 Transaction block. 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