#33984: Related managers cache gets stale after saving a fetched model with new 
PK
-------------------------------------+-------------------------------------
     Reporter:  joeli                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Keryn Knight):

 In ''theory'' the "simplest" solution (to keep the caching behaviour and
 allow the documented duplication method) is to special-case `None` as a pk
 value and always instantiate a fresh manager, circumventing the cache
 entirely.
 I think though that the problem ''technically'' extends further, any
 change to the `pk` -- or more specifically, the manager's core filter
 dependencies -- would become stale subsequently. Unsupported those other
 cases may be from a documentation standpoint, but I'm sure someone
 somewhere is doing it...

 If there's a path where we (I) can invalidate correctly, and it keeps the
 overall improvement of #32980, and it's not too invasive or complex, we
 can try and proceed on that basis. If the change restores the ''old''
 performance behaviour in the process, there's not much argument (except
 maybe memory pressure/garbage collection) to keeping the cache
 functionality, off the top of my head.

 Basically there's two things to check there above, and if either of them
 is a miss, I guess we'd revert #32980 because I can envisage ''plenty'' of
 cases where people use the `pk=None` trick to clone an instance,
 documented as it is.

 I may assign this out to myself in the near future if it's otherwise not
 picked up, assuming I can find the availability.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33984#comment:6>
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/010701831c56744d-36f5f415-726d-401a-9b0f-c34c33640fdb-000000%40eu-central-1.amazonses.com.

Reply via email to