#19707: TransactionMiddleware leaks transaction state -------------------------------------+------------------------------------- Reporter: akaariai | Owner: nobody Type: Bug | Status: closed Component: Database layer | Version: 1.4 (models, ORM) | Resolution: fixed Severity: Release blocker | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 0 | Patch needs improvement: 1 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by akaariai): The fix has caused a regression for 1.4.x when running tests under postgis, specifically these two tests: `gis requests`. For some reason a connection will be left open. The reason is linked to `del connections[conn]` in close_connection(). Also, if the requests.test_request_finished_failed_connection assigns the old conn to `connections["DEFAULT_DB_ALIAS"]` then everything will work. I don't yet know what exactly is happening. Still, it seems that the del connections[conn] is a bad idea, at least for 1.4. Maybe it would be better to try to clean the transaction state variables of the connection directly. But, for example postgresql has .isolation_level variable which should be cleared to proper state so that the `options['autocommit']` feature will continue to work properly. This is done by leave_transaction_management(). Cleaning the state otherwise than by doing leave_transaction_managment() is risky, but maybe it is still the least risky approach... I will continue investigating this tomorrow. -- Ticket URL: <https://code.djangoproject.com/ticket/19707#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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.