#36489: OneToOneField + concurrent get_or_create results in wrong object in 
field
cache
-------------------------------------+-------------------------------------
     Reporter:  Brian Atkinson       |                    Owner:  Jason
                                     |  Hall
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  5.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Rushabh Doshi):

 Natalia, Simon and Sarah - thank you for looking at this issue and the
 patch.
 Jason - thanks for making the patch in the first place.

 Given that the patch doesn't seem to fully solve the problem, and given
 that this issue affects all OneToOneFields and causes a subtle data
 corruption that could be hard to detect and diagnose, I have two
 questions:
 1. Is there a way to raise awareness of this issue and seek help in
 fixing? We would offer to give it a shot, but this is very deep ORM code
 and we don't feel like we have sufficient experience to attempt the patch.
 2. In the meantime, could you advise on the work around? My current
 thought is that we should use ForeignKey(unique=True) and eat the Django
 check warning
 
https://github.com/django/django/blob/main/django/db/models/fields/related.py#L1079
 This would force us to use `child_set.first()` but that's a small
 ergonomic price to pay. Do you have any thoughts on this approach or a
 better suggestion instead?
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36489#comment:14>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070198f37a6778-8de45033-577e-4271-960e-3f94660cc156-000000%40eu-central-1.amazonses.com.

Reply via email to