Opened 14 years ago

Closed 14 years ago

#16352 closed Bug (duplicate)

Simultaneous user work with django.contrib.admin

Reported by: pelid80@… Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

IndexError at /admin/expositions/exposition/
list index out of range

...

/mnt/sites/mt3/locals/virtualenv/lib/python2.6/site-packages/django/forms/models.py in _construct_form
kwargs['instance'] = self.get_queryset()[i]

/mnt/sites/mt3/locals/virtualenv/lib/python2.6/site-packages/django/db/models/query.py in __getitem__
return self._result_cache[k]

Error occur when few user work with the same editable list:

  • Alice views editable list of expositions A, B, C and D
  • Bob removes exposition D
  • Alice saves changes in list
  • Error happens during new formset creation. There is no 4th element in expositions query

Change History (2)

comment:1 by Aymeric Augustin, 14 years ago

Triage Stage: UnreviewedDesign decision needed

To the best of my knowledge, the admin doesn't implement any kind of locking or collision detection. Such race conditions trigger a 500.

The problem itself can't be solved: anything could alter the database outside of Django's control. Even if only Django touches the database, objects can be deleted by any code, and the admin has no way of knowing what happens.

Django could try to handle this kind of error more gracefully, but I'm not sure we want to do that. A 500 page usually says "please retry later"; the user will press "Back", "Refresh", see that a row has disappeared, and figure out what happened. It's fairly easy to implement optimistic locking if you need it.

Related discussion on SO: http://stackoverflow.com/questions/320096/django-how-can-i-protect-against-concurrent-modification-of-data-base-entries

comment:2 by Julien Phalip, 14 years ago

Resolution: duplicate
Status: newclosed

This was in fact already reported in #11313. See also #11652 for a related issue.

Note: See TracTickets for help on using tickets.
Back to Top