On Tue, Aug 28, 2018 at 7:50 AM, Mohit Agarwal <[email protected]>
wrote:

> Hi,
> We are seeing exceptions:AssertionError being raised when of our APIs has
> a long running query. In code we are rolling back transaction if any error
> is received while committing. Basically we have this general wrapper
>
> try:
>  session.commit()
> except:
>  session.rollback()
>
>
>
> Our sql alchemy version - 1.0.6
> Our database - Azure SQL (sql server)
>


that's a very old SQLAlchemy version, I can't say what the issue is but at
least would need the complete stack trace and the complete error messages
including the "inner" stack trace, e.g. what you are actually catching with
that "except".    The session is likely already being rolled back within
the scope of the "commit" and then some state issue is preventing
rollback() from working again.   There have been fixes in the area of
Session state management over the years so the first step would be
upgrading to a 1.1 or 1.2 version of SQLAlchemy to see if that resolves.


>
>
> Stack trace -
> File "/code/api/named_location/resources.py", line 258, in
> create_named_locations_dataclass
> File "/code/api/named_location/operations.py", line 94, in do_create
> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py",
> line 150, in do
> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py",
> line 754, in rollback
> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py",
> line 437, in rollback
> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py",
> line 273, in _restore_snapshot
>
> From the code it looks like it fails here -
> def _restore_snapshot(self, dirty_only=False):
> *assert self._is_transaction_boundary*
> What does it mean, why rollback is failing ?
>
>
>
> Thanks
> Mohit
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to