#13906: REPEATABLE READ (as used by default on MySQL) breaks atleast
QuerySet.get_or_create().
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:
  sebastian_noack                    |         Status:  new
                   Type:             |      Component:  Database layer
  Cleanup/optimization               |  (models, ORM)
              Milestone:  1.4        |       Severity:  Normal
                Version:  SVN        |       Keywords:  mysql transaction
             Resolution:             |  isolation
           Triage Stage:  Accepted   |      Has patch:  1
    Needs documentation:  1          |    Needs tests:  0
Patch needs improvement:  1          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 SELECT FOR UPDATE does not solve this. At least in PostgreSQL if there is
 no row there, then it does nothing. MySQL's documentation says it has the
 same behavior. So, if there are 2 transactions inserting, then you would
 have:

 {{{
 SELECT FOR UPDATE # Sees nothing, thus locks nothing.
 # Another transaction inserts a row
 # another transaction commits
 INSERT # can't insert, IntegrityError
 SELECT # can't see it.
 }}}

 I am not completely sure of this, but it seems that in REPEATABLE READ
 there is nothing you can do. By definition you can't see the row of the
 other transaction if it was not visible in the beginning of your
 transaction. Unique index ensures you can't insert it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/13906#comment:21>
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.

Reply via email to