-
Notifications
You must be signed in to change notification settings - Fork 91
Avoid implicit commits #90
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error probably does not need to be included in the error list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that. But then again I think it is good to have all the error that occurred. Also, I am using this list at the moment to test, whether the handling of TransactionErrors is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The returned error list is for the user to debug and it should only include unresolved problems. If the error is resolved, it should not be returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the error list is not empty, it means something failed to populate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an implicit assumption I did not know about. However, I think
- The user might want to know about it, since she causes a transaction to rollback simply because she did not declare a table. That might cost computational time and is easy to avoid.
- If she uses it for debugging/error resolving, she can just ignore TransactionErrors. So I don't see the problem for debugging. It is, after all, still an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this pull-request has already been merged, but wasn't sure if we resolved this issue surrounding the error list. Are we going with the solution provided by @fabiansinz ? or should we discuss this separately as an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No matter what solution we agree on, I think it should have two features:
- There should be a way to check whether TransactionErrors have been raised (and dealt with). I think this is important information for the user (I guess no one likes to compute something again just because he forgot to declare a table) and I'd like to have that feature for testing.
- We should make it very clear that only unhandled errors are part of the error list. Otherwise I think the current behaviour is unexpected. That's why I decided to add the errors to the list. That said, if errors are not suppressed, then currently the user does not see the error at all. I don't like that part of the current solution. I actually favour always returning an error list with the possibility that it is empty. That error list should then also contain the TransactionErrors.
Avoid implicit commits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor point, but the comment should read # key is not populated yet now to reflect the change in code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll change it directly in the master branch.
|
Sorry I rushed to merge this. I think these new changes are overly complex and buggy. Too many things happening behind the scenes across multiple locations in the code. I am all for using python's clever features as long as they make things clearer, more efficient and explicit. I recommend removing the if self.conn.in_transaction:
raise TransactionError("this function cannot be called from within a transaction")in two places in the code with something much more elaborate and distributed. It makes the code harder to read and understand. It also adds an extra dependency, complicates the call stack, and makes debugging more difficult. It takes more time to understand and use than the original constructs. I am not sure about the |
|
Please specify where it is buggy. |
|
In the current master 2f35539, |
|
I fixed these bugs in my pull request (issue #91) |
|
I agree that it is not the most elegant way and that setting the boolean belongs in the other methods, but it is not a bug. Arguing that I can't see that your request got closed. |
|
Concerning the complexity: The decorator:
|
|
If you are calling Connection._start_transaction() then let it set its internal state. The bug is that if someone else calls |
|
No matter how many times Sorry, I didn't quite understand how this |
|
The function that throws the TransactionError passes itself and its arguments to the error. This allows the function that caused the transaction to catch the error, rollback, and then resolve it by calling |
|
I think it would make more sense for us to take this discussion offline. In general, it looks like we need to sync up on how some of these implementations should work out based on expected use cases. Having classes like |
|
Okay, I understand. You want to invoke the DDL method again outside the transaction before attempting the transaction again. It's clever but I don't feel good about control flow now spanning three files. I would feel better about throwing a simple unhandled exception to the user saying "Sorry, please declare all your tables first before populating them." I don't feel good about the running and failing |
|
Yes, the |
|
I agree with @eywalker. See my email to you two. |
|
I know we decided to take this offline, but I would like to put a general reminder as I see this fit in closing the discussion here. An implementation is not a bug in so far as that's the expected behavior - if a feature has been implemented under different understanding about what's expected, we should be careful not to call it a bug, but rather take it as a sign that, as a team, we have to more carefully discuss and agree upon what's the expected behavior. We've been getting quite a bit done with fun, so let's plan to keep it that way. |
@not_in_transactionthat throws a TransactionError if the decorated function is called during a transactionpopulateexplicitly catches the TransactionError. The TransactionError object holds the function and the parameters that caused the error. It uses that to provide a functionresolvewhich just calls the function again with the same arguments. So ifpopulatecatches a TransactionError, it can just callresolve(because it is not in a transaction anymore), resolve the error, and restart the transaction.