You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Transaction is left open when error happens in Datastore API #2297
This one is hard to reproduce, but I noticed that when using a transaction with a with statement and an error happens inside the transaction itself (a 500 error for example), it appears that the transaction is left open.
withself.client.transaction():
# do stuff# create entities, put, put_multi, etc
After the exception, any operations to the Datastore using the same client have no effect, and no error is reported.
So my guess is that for some reason the transaction was left open and the changes are never committed.
@dmho418 It occurred to me while making the fix #2303 that this error would really only be perceivable if you were in the interpreter or some other situation where the uncaught exception didn't hose your entire application. Are you catching errors and recovering somehow? You may want to look into how much "recovery" is done.
@tseaver I wanted to make sure that a failure in __enter__ means __exit__ is never called AND that the failure in __enter__ bubbles up to the user:
@dhermes you got it, I'm catching that exception since I don't want the application to crash. Ideally, the client should remain valid after the exception, right?
Activity
tseaver commentedon Sep 12, 2016
Thanks for the report!
dhermes commentedon Sep 12, 2016
I was able to reproduce this, digging in now.
dhermes commentedon Sep 12, 2016
After just faking the 500
I ran the following:
The issue is certainly in
Batch.__enter__, hope to have it sorted out soon.Making datastore batch/transaction more robust to failure.
Making datastore batch/transaction more robust to failure.
dhermes commentedon Sep 12, 2016
@dmho418 It occurred to me while making the fix #2303 that this error would really only be perceivable if you were in the interpreter or some other situation where the uncaught exception didn't hose your entire application. Are you catching errors and recovering somehow? You may want to look into how much "recovery" is done.
@tseaver I wanted to make sure that a failure in
__enter__means__exit__is never called AND that the failure in__enter__bubbles up to the user:dmho418 commentedon Sep 16, 2016
@dhermes you got it, I'm catching that exception since I don't want the application to crash. Ideally, the client should remain valid after the exception, right?
dhermes commentedon Sep 16, 2016
Yeah, #2303 resolves that issue. Thanks for bringing it to our attention.
refactor: fix ops.StrftimeOp, ops.ToDatetimeOp, ops.ToTimestampOp in …