On Sunday 03 March 2013, Jacob Kaplan-Moss wrote: > Shai: do you have any real-world code that'd have data loss > with this bug?
The code in sites I work on usually uses transaction middleware or @commit_on_success, so it would not suffer (nor benefit) from this change. So I tried to look for openly available code. I found this very clear example on Stack Overflow -- I'm not sure it counts as "real-world code", but it definitely becomes subtly broken with database-level autocommit: http://stackoverflow.com/questions/8965391/delete-duplicate-rows-in-django-db Then I turned to somewhere I thought might be susceptible, and took a look at django-mptt. I wish I had more time and stamina at this point to find an actual smoking gun, but what I did find, was no use of transaction control: Not in code (the only transactional code is a call to transaction.commit_unless_managed at the end of the move_node operation), and not even in documentation (except for docstrings for context-managers which delay updates). The code there is pretty complex and abstract, but I'm pretty sure it does make decisions based on reads that affect consequent writes -- and I'm pretty sure that adding a commit between the former and the latter will make it fragile in new and interesting ways. So that is real-world code that I'm almost sure now has data loss possibilities, unless used in explicit transactions. Which brings me to this comment: > Looking through the tons of code I've got available > can't reveal a single place where this chance would have any negative > effect. OTOH, there're lots of places where it'd have a positive > effect. > Please correct me if I'm misunderstanding: For this to hold, you need lots of pieces of code where autocommit is on (otherwise there's no positive effect), and then you need to be sure that, in all these places, either reads don't really affect consequent writes, or some constraint holds that is equivalent to serializability -- otherwise, negative effect is possible. That sounds quite implausible. Is the implausible really the case? Otherwise, what am I missing? Thanks, Shai. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.