Skip to content

Two phase support for sessions / threadedlocal engine #936

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Anonymous

The threadlocal engine uses sessions for it's transaction support, and these do not support two phase commit.

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Feb 19, 2008

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

hmm maybe ants has some time for this one, or I can get to it, it should be fairly straightforward. Do you have an immediate need for this ?

sqlalchemy-bot

sqlalchemy-bot commented on Feb 19, 2008

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • added labels: engine
  • set milestone to "0.4.xx"
sqlalchemy-bot

sqlalchemy-bot commented on Feb 26, 2008

@sqlalchemy-bot
CollaboratorAuthor

Anonymous wrote:

This patch fixes it for me. It was mostly there already. Laurence (l@lrowe.co.uk)

Index: lib/sqlalchemy/engine/threadlocal.py
===================================================================
--- lib/sqlalchemy/engine/threadlocal.py        (revision 4192)
+++ lib/sqlalchemy/engine/threadlocal.py        (working copy)
@@ -38,17 +38,9 @@
 
     def prepare(self):
         if self.__tcount == 1:
-            try:
-                self.__trans._trans.prepare()
-            finally:
-                self.reset()
+            self.__trans._trans.prepare()
 
     def begin_twophase(self, xid=None):
-        raise NotImplementedError(
-            "Two phase transactions not yet implemented for 'threadlocal' "
-            "strategy")
-
-    def _dont_begin_twophase(self, xid=None):
         if self.__tcount == 0:
             self.__transaction = self.get_connection()
             self.__trans = self.__transaction._begin_twophase(xid=xid)
sqlalchemy-bot

sqlalchemy-bot commented on Feb 26, 2008

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

OK, I implemented that patch plus methods directly on TLEngine itself (since the API is typically from the engine) as well as a rudimentary test in 82edfd0. What's not tested there is more complex interactions between standalone connections, transactions, and TLEngine but the idea for basic usage should be good.

thanks for the patch !

sqlalchemy-bot

sqlalchemy-bot commented on Feb 26, 2008

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added
engineengines, connections, transactions, isolation levels, execution options
on Nov 27, 2018
added this to the 0.4.xx milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineengines, connections, transactions, isolation levels, execution optionsfeature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          Two phase support for sessions / threadedlocal engine · Issue #936 · sqlalchemy/sqlalchemy