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

Safety when we get an error during transaction begin #23

Closed
wants to merge 1 commit into from

Conversation

jzuech3
Copy link

@jzuech3 jzuech3 commented Sep 5, 2019

Resolves #18

@jamadden
Copy link
Member

jamadden commented Sep 5, 2019

Conflicts with the more extensive changes in #21, which should also fix #18. (The cause of #18 was the del tx, not it being 'None'.)

@jzuech3
Copy link
Author

jzuech3 commented Sep 5, 2019

Agreed. Merge that first. Even if we remove the del tx, we'll need to handle tx being None in _retryable.

@jamadden
Copy link
Member

jamadden commented Sep 5, 2019

Nah, if txm.begin() fails, something terrible happened. It's unlikely that it'd be a retryable exception. That just needs to be outside the scope of the retry logic. (RelStorage even has special logic to make sure that if something retryable does happen during txm.begin() -> Connection.newTransaction -> storage.poll_invalidations() it gets deferred until later; no one expects txm.begin() to fail. Which, now that I think about, may be slightly incomplete in newer versions...)

@jzuech3
Copy link
Author

jzuech3 commented Sep 5, 2019

Ah, ok. We can probably delete this PR then. #18 was caused by an issue during tx.begin right?

@jamadden
Copy link
Member

jamadden commented Sep 5, 2019

#18 was caused by an issue during tx.begin right?

Possibly, but not necessarily. There used to be del tx while we were still inside the scope of the try/except handler, and the arrival of a signal, say, could happen after del tx but before exiting the try/except block. Other conditions detected by the VM like MemoryError could also happen in that window.

@jamadden jamadden closed this Sep 5, 2019
@jzuech3 jzuech3 deleted the begin_tx_errors branch September 5, 2019 21:13
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

Successfully merging this pull request may close these issues.

UnboundLocalError: local variable 'tx' referenced before assignment
2 participants