#33516: QuerySet update() under postgres with 
select_for_update(skip_locked=True)
results in neither FOR UPDATE nor SKIP LOCKED
-------------------------------------+-------------------------------------
     Reporter:  Grant Gainey         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 In the latest version of Django
 
[https://github.com/django/django/blob/7119f40c9881666b6f9b5cf7df09ee1d21cc8344/django/db/models/sql/query.py#L2161-L2171
 the ordering should not be cleared] when `select_for_update` is used on
 the subquery provided to a `__in` lookup.


 {{{#!python
 def update_timestamp(index):
     content_q = (
         TestModel.objects.order_by("pk")
         .select_for_update(skip_locked=True)
         .values_list("pk", flat=True)
     )
 TestModel.objects.filter(pk__in=content_q).update(timestamp_of_interest=now())
 }}}

 There was some recent changes in this area in 4.0 and I haven't confirmed
 if this is an issue on 3.2 but in all cases `order_by.select_for_update`
 has to be called on the subquery and not the outer one for this to work as
 the resulting SQL hints at and that's likely why your solution isn't
 working here.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33516#comment:1>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.da41cf03ab87298a92c8db5f260246dc%40djangoproject.com.

Reply via email to