#26630: Defered constraint checks flush after `post_delete` signal
-------------------------------------+-------------------------------------
     Reporter:  Alex Madjar          |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  duplicate
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

 * resolution:   => duplicate
 * status:  assigned => closed

Comment:

 I'm also a little unsure. I think the gist of the report is that doing
 database queries during a `post_delete` listener is problematic, because
 you can query `Choice` rows by `question_id` and get misleading results
 (as those rows are in the middle of being cascade deleted).

 I'm reading the original report to suggest reordering the `post_delete`
 signal to run after constraints are flushed (and all cascade deletes have
 happened). I doubt that would be backward compatible.

 In #30835 something similar was suggested, and Simon explained you can use
 `on_commit()` to defer execution of the callback (to a point when all
 cascade deletions have been made). I think I'd suggest rewriting the
 signal handler that way to avoid this problem with unstable `Choice`
 results.

 I'm inclined to close this as duplicate of #30835. As mentioned there, if
 there's a proposal for a docs tweak in `post_delete` we could consider it.
 (In that case, do reopen #30835!)

 Thanks for helping out with triage.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/26630#comment:12>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019bb8c7c6cb-0cf5714a-51cb-4edf-8f03-052087177a12-000000%40eu-central-1.amazonses.com.

Reply via email to