#27477: Use QuerySet.select_for_update() in admin change form to fix race 
condition
-------------------------------+--------------------------------------
     Reporter:  Dave Hall      |                    Owner:  nobody
         Type:  New feature    |                   Status:  new
    Component:  contrib.admin  |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:  admin          |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by Dave Hall):

 Sure, will do. Probably this week.

 It's going to be hard to do this in a way that doesn't hurt backwards
 compatibility. There are a few options we can do:

 1. Make the get_object() method take a for_update boolean keyword arg.
 This will have backwards-compatibility problems.
 2. Make the get_object() method call select_for_update() on the queryset
 if the HTTP method is POST, PUT, PATCH or DELETE. This may result in
 spurious select_for_update() calls on the queryset, but is backwards
 compatible.
 3. Make the get_queryset() method call select_for_update() on the queryset
 if the HTTP method is POST, PUT, PATCH or DELETE. This may result in
 spurious select_for_update() calls on the queryset, but is backwards
 compatible.

 I think that (2) or (3) is the correct approach. I'm erring on the side of
 (3), since it'll also help with admin bulk actions.

 All approaches can be applied to the admin admin generic views. Do people
 have a preference as to the approach?

--
Ticket URL: <https://code.djangoproject.com/ticket/27477#comment:5>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.432e09c5996a4da9ca69071b6ad37901%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to