Skip to content

Conversation

@ahopkins
Copy link
Owner

@ahopkins ahopkins commented Oct 28, 2025

This pull request introduces significant improvements to Mayim's transaction system, focusing on simplifying transaction management, fixing rollback bugs, and providing proper connection isolation. The changes refactor how transactions are tracked, enhance the transaction API to support SQL isolation levels, and unify transaction handling across single and multi-executor scenarios. Several files have also been updated for code clarity and maintainability.

Transaction system refactor and improvements:

  • Replaced the use of ContextVar for tracking transaction state in mayim.base.interface.py with a simpler instance variable, improving connection isolation and fixing bugs related to transaction rollback. Added methods for setting and clearing the transaction connection. [1] [2]
  • Refactored the transaction API in mayim.py to accept a new isolation_level parameter, supporting both string and enum values. Added normalization and validation for isolation levels, and ensured the correct propagation to the transaction coordinator. [1] [2]
  • Unified transaction handling in sql/executor.py, so single-executor transactions now use the TransactionCoordinator internally. This fixes bugs with rollback/commit and ensures consistent transaction management.
  • Added a new transaction module with a clean implementation of the transaction coordinator, isolation level enums, and related error classes.

Codebase cleanup and clarity:

  • Replaced single-line ellipsis class definitions with explicit pass statements for error and default classes to improve readability and maintainability. [1] [2] [3]
  • Minor documentation and formatting improvements in registry and interface files for clarity. [1] [2]

Other updates:

  • Bumped the package version to 1.3.0 in setup.cfg.
  • Updated connection acquisition logic in postgres/interface.py to use the new transaction connection tracking.

These changes collectively make transaction handling in Mayim more robust, easier to use, and less error-prone, especially in complex or multi-executor scenarios.

@ahopkins ahopkins merged commit bedd695 into main Oct 28, 2025
6 checks passed
@ahopkins ahopkins deleted the txn branch October 28, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants