#16047: postgresql_psycopg2 never restores autocommit mode when leaving transaction management -------------------------------------+------------------------------------- Reporter: brodie | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.3 (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: psycopg2 autocommit | Needs documentation: 0 transactions | Patch needs improvement: 0 Has patch: 1 | UI/UX: 0 Needs tests: 0 | Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by akaariai): What happens is: - when you enter transaction management "True" is appended to the transaction_state stack. - when you leave transaction management, currently top of the stack (True) is given to _leave_transaction_management(). This tells "where we are coming from". - my patch changes this in a way that the "True" is popped from the stack, and then what is left is given to _leave_transaction_management. Now, this is correct, because when setting the isolation level, we are not interested if we came from a managed block or not, we are interested if we are going into a managed state. - ignoring totally the managed parameter is wrong, because you can stack enter/leave calls. This would lead into situation where the first leave always sets you into autocommit mode, no matter how many enter calls there have been before. This is tested in the patch. About the managed parameter: don't ask. The transaction management code could be cleaner... About the try-except: True, that change is not necessary, it just seemed better to me. "Pop the stack, it is an exception if it is empty". I ran the full test suite and got some errors. However, I don't think they are related to this patch, but to some other recent commits. If you can review & mark the patch as ready for committer that would be great. -- Ticket URL: <https://code.djangoproject.com/ticket/16047#comment:9> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.