-
Notifications
You must be signed in to change notification settings - Fork 25
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
MailDataManager breaks the transaction manager upon abort #31
Comments
i'll take a look tonight and try to recreate the error. sorry this happened. i lifted most of the code from the zope sqlaclhemy extension. it's had some updates, so I may be able to find some answers there. |
I'm tempted to revert the changes in 4.2 and release a 4.3 that is actually just 4.1, as this issue is pretty serious. |
Chris- I think that's a good idea.
Michael- I agree on no abort in phase 2.
|
quick note, nowhere near a solution, but i've been making some progress on this in my fork [https://github.com/jvanasco/repoze.sendmail] readability
|
…2, which breaks transaction management see repoze/repoze.sendmail#31 for more info...
See repoze/repoze.sendmail#31 for detailed information
Neccessary until repoze/repoze.sendmail#31 is resolved.
Interesting. I'm stumbling over a "domain not found" and I really don't care. Downgrading to 4.1 doesn't fix it. This ends up in half-deliveries :( |
From what I can see the most reasonable part would be to bare-except the send() method completely: in the special case of email, I don't see why uncontrollably failing the whole transaction is better than to best-effort this. This is email anyway. We could do better if the data manager would have more control over the whole process and move some of the communication to the first phase (like rcpt, or other stuff). |
After struggling to debug this issue (and also related issue #30), I think the best and simplest approach is to reset the "tpc_phase" value to 0 after a two-phase commit completely finished or aborted. It then will not fail any later transaction.abort() calls. So both issues would be resolved. I've implemented my fix in a fork vietdt@aba1cc5. Not sure if it works correctly and could be merged upstream. diff --git a/repoze/sendmail/delivery.py b/repoze/sendmail/delivery.py
index 59115d7..28b7cf4 100644
--- a/repoze/sendmail/delivery.py
+++ b/repoze/sendmail/delivery.py
@@ -102,6 +102,7 @@ class MailDataManager(object):
if self.transaction is None:
raise ValueError("Not in a transaction")
self.state = final_state
+ self.tpc_phase = 0
def commit(self, trans):
if self.transaction is None: Also found the same implementation in a test script in transaction package |
@vietdt Your suggested fix looks correct to me. @mmerickel can you test it against your failing case? |
@tseaver it seems there's no response from @mmerickel. Could anyone help on testing to confirm the fix? If the fix is correct, I would like to use it from mainstream package rather than from a fork or have to pin to version 4.1. |
Will there be a 4.3 release w/ the fix for this issue? |
I have some code sending emails and for legitimate reasons the email is rejected by the remote server. I want to log the exception but instead I see the
ValueError('TPC in progress')
a couple times in the output, squashing the error.It's actually causing the transaction manager to be in such a broken state that the next transaction.manager.begin() after the failed abort, causes another exception. Below is the crap fix to prove the diagnosis, but I'm not positive it's the correct fix. I downgraded to 4.1 and things work as expected.
From what I can tell this behavior appeared in 06ad882 when the manager was rewritten.
On a related side note, aborting in the second phase of a two-phase commit is a Really Bad Thing(tm). Since sending email isn't transactional it almost makes more sense to either send the email in an earlier phase or even as an
afterCommitHook
.The text was updated successfully, but these errors were encountered: