Hi Bart, On 05/16/2016 02:10 PM, barthel...@infobart.com wrote: > I believe that I encountered a bug or at least a serious limitation with > transaction.on_commit in Django 1.9.x. Essentially, the on_commit hooks > seem to be tied to the database connection instead of the transaction. > This means that unrelated transactions may trigger on_commit hooks, > which results in undesired execution order. [...] > I wanted to know if someone encountered this issue or if I am > misunderstanding on_commit before opening a ticket.
I am the author of on_commit, and I think the behavior you have encountered is a bug that should be fixed. Doing additional database work in `on_commit` callbacks wasn't really a use case I had in mind in the design; I made sure it basically worked, but clearly didn't explore it sufficiently in cases of multiple registered hooks. Storing the on_commit state on the connection is not really optional, since that's where _all_ transaction-related state is stored, but I think it should still be possible to fix this. Perhaps by having `run_and_clear_commit_hooks` copy the list of hooks into a local variable and immediately clear the state on the connection before it calls any of the hooks? Not entirely sure, need to add a failing test and play with it a bit. Thanks for catching and reporting this. If you'd be willing to file a ticket in Trac, that'd be great. Carl -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/573AB193.5020807%40oddbird.net. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature