[Django] #29202: KeyError in django-sites caching (race condition?)

28 views
Skip to first unread message

Django

unread,
Mar 8, 2018, 8:24:44 AM3/8/18
to django-...@googlegroups.com
#29202: KeyError in django-sites caching (race condition?)
------------------------------------------+------------------------
Reporter: Dominik George | Owner: nobody
Type: Bug | Status: new
Component: contrib.sites | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
Django Version: 1.10.8
Python Version: 3.5.3

Relevant backtrace:

{{{
File
"/srv/www/teckids-website/venv/lib/python3.5/site-
packages/django/contrib/sites/models.py"
in _get_site_by_id
37. return SITE_CACHE[site_id]

File "/srv/www/teckids-website/venv/lib/python3.5/site-
packages/multisite/hacks.py" in
__getitem__
124. raise KeyError(key)
}}}

In theory, there cannot be a KeyError there, unless the cache is cleared
while the method is running. The code does not seem to be thread-safe.

--
Ticket URL: <https://code.djangoproject.com/ticket/29202>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 12, 2018, 10:41:13 AM3/12/18
to django-...@googlegroups.com
#29202: KeyError in django-sites caching (race condition?)
--------------------------------+--------------------------------------

Reporter: Dominik George | Owner: nobody
Type: Bug | Status: new
Component: contrib.sites | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Dominik George):

After a discussion at Chemnitzer Linux-Tage with some Django people, we
agreed it is a bug, but maybe related to Apache mpm_prefork's multi-
threading behaviour.

We reduced the threads in each process to 1 in the mod_wsgi config, but
the error still occured after that.

--
Ticket URL: <https://code.djangoproject.com/ticket/29202#comment:1>

Django

unread,
Mar 15, 2018, 9:00:46 PM3/15/18
to django-...@googlegroups.com
#29202: KeyError in django-sites caching (race condition?)
--------------------------------+--------------------------------------

Reporter: Dominik George | Owner: nobody
Type: Bug | Status: new
Component: contrib.sites | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Tim Graham):

I'm not sure. The fact that the traceback involves `multisite/hacks.py`
(which is not part of Django) looks a bit suspicious.

--
Ticket URL: <https://code.djangoproject.com/ticket/29202#comment:2>

Django

unread,
Mar 16, 2018, 6:27:46 AM3/16/18
to django-...@googlegroups.com
#29202: KeyError in django-sites caching (race condition?)
--------------------------------+--------------------------------------

Reporter: Dominik George | Owner: nobody
Type: Bug | Status: new
Component: contrib.sites | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Dominik George):

Yeah. I am not saying the CMS isn't part of the problem, but I don't need
a backtrace to tell that the code in Django is neither thread-safe nor
otherwise good practice ☺.

--
Ticket URL: <https://code.djangoproject.com/ticket/29202#comment:3>

Django

unread,
Mar 22, 2018, 11:20:15 AM3/22/18
to django-...@googlegroups.com
#29202: KeyError in django-sites caching (race condition?)
--------------------------------+--------------------------------------

Reporter: Dominik George | Owner: nobody
Type: Bug | Status: new
Component: contrib.sites | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Tim Graham):

I'm skeptical because I'd think that if this were a common issue, we'd
have seen it reported before now.

I don't know what can be done. Are you able to offer a patch?

--
Ticket URL: <https://code.djangoproject.com/ticket/29202#comment:4>

Django

unread,
Mar 24, 2018, 8:21:35 PM3/24/18
to django-...@googlegroups.com
#29202: KeyError in django-sites caching (race condition?)
--------------------------------+--------------------------------------

Reporter: Dominik George | Owner: nobody
Type: Bug | Status: closed
Component: contrib.sites | Version: 1.10
Severity: Normal | Resolution: needsinfo

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 Tim Graham):

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


--
Ticket URL: <https://code.djangoproject.com/ticket/29202#comment:5>

Django

unread,
Apr 9, 2018, 7:32:01 AM4/9/18
to django-...@googlegroups.com
#29202: KeyError in django-sites caching (race condition?)
--------------------------------+--------------------------------------

Reporter: Dominik George | Owner: nobody
Type: Bug | Status: closed
Component: contrib.sites | Version: 1.10
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Dominik George):

Nope, it's not a duplicate.

--
Ticket URL: <https://code.djangoproject.com/ticket/29202#comment:6>

Reply all
Reply to author
Forward
0 new messages