Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A failed join leaves zope.sqlalchemy in an inconsistent state #2

Closed
hgarus opened this issue Aug 26, 2013 · 6 comments
Closed

A failed join leaves zope.sqlalchemy in an inconsistent state #2

hgarus opened this issue Aug 26, 2013 · 6 comments

Comments

@hgarus
Copy link
Contributor

hgarus commented Aug 26, 2013

I am not entirely sure if this is a bug, but the current behavior could at least be considered suboptimal:

When the ZopeTransactionExtension triggers a join, while the state of the zope transaction is COMMITFAILED a TransactionFailedError will be raised and the _SESSION_STATE entry of the sqlalchemy session will be left behind.

If the sqlalchemy session is reused in the future (ie because it is threadscoped) it won't be joined to the zope transaction at all, since it already has a corresponding entry in _SESSION_STATE. This causes the sqlalchemy transaction to remain open, which can lead to a database transaction being "wedged" until it is closed due to a database timeout or a restart of the zope instance.

I am not sure if a join should even be attempted if the transaction is in COMMITFAILED. Doing operations on the sqlalchemy session while the zope transaction is in this state could probably be considerer a bug on the user's side. But I believe this should be addressed in some way.

@jinty
Copy link

jinty commented Aug 27, 2013

This definitely sounds like a bug to me. The join_transaction() call should definitely raise an error loudly, but not cause a "wedged" session and affect future transactions.

Could you write a test which demonstrates the failure? For example testAbortAfterCommi" is a regression test for a problem which resulted in a similar "wedged" session.

@hgarus
Copy link
Contributor Author

hgarus commented Aug 27, 2013

I have added a test demonstrating this behavior:

hgarus@970a2da

@jinty
Copy link

jinty commented Aug 30, 2013

Thanks. I committed your test and a fix:

a3d9c95

@jinty jinty closed this as completed Aug 30, 2013
@cjw296
Copy link

cjw296 commented Aug 30, 2013

Any idea when the next release will be?

@jinty
Copy link

jinty commented Aug 30, 2013

On Fri, Aug 30, 2013 at 01:39:08AM -0700, Chris Withers wrote:

Any idea when the next release will be?

Nope.

Brian Sutherland

@mgedmin
Copy link
Member

mgedmin commented Aug 30, 2013

PyPI says this about zope.sqlalchemy:

Package Index Owner: laurencerowe, chrism

I believe laurencerowe is @lrowe and chrism is @mcdonc. Only they can make releases.

aadis pushed a commit to ideadevice/zope.sqlalchemy that referenced this issue Nov 26, 2013
When a join is attempted while the transaction is in COMMITFAILED
zope.sqlalchemy is left in an inconsistent state.

See zopefoundation#2
aadis pushed a commit to ideadevice/zope.sqlalchemy that referenced this issue Nov 26, 2013
If the join() errors, _SESSION_STATE does not get
wedged.

fixes zopefoundation#2
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

No branches or pull requests

4 participants