Nested transactions/savepoints loose connections

Issue #942 resolved
Former user created an issue

When using nested transactions/savepoints, the associated connections seem to never get returned to the pool.

My patterin is:

t = session.begin_nested() session.commit()

When switching on echo=True I do not see a commit actually go to the database, only a release savepoint statement. Also, the connection is not returned to the pool, so that an open connection hangs around that isn't closed when I dispose the engine.

Comments (4)

  1. Former user Account Deleted
    • assigned issue to
    • changed component to orm
    • changed milestone to 0.4.xx

    (original author: ants) You were probably using a transactional session (the default), which starts a transaction automatically on creation. When issuing a begin_nested() a subtransaction is actually started. So when you issue a commit() that nested transaction is commited (in practice, the savepoint is released), but the outer transaction stays open and correctly holds on to the connection.

    When verifying this I noticed some other problems regarding session transactions. For example, begin(), begin_nested(), save(obj), commit() save(obj), commit() inserts the objects in two different transactions and the connection isn't returned to the pool for some reason (gc.collect() doesn't help). Another problem is that session.commit() and transaction.commit() don't get along very well.

    The docs leave the transaction semantics of session kind of open. I'll figure out what the correct behaviour should be and fix/document it this weekend.

  2. Log in to comment