disqus / gargoyle

Feature switches in Django
http://engineering.disqus.com
Apache License 2.0
746 stars 112 forks source link

Concurrency issue? #100

Open martino opened 8 years ago

martino commented 8 years ago

Hi using gargoyle.is_active we've found in our sentry this exception:

Stacktrace (le chiamate più recenti alla fine):

  File "django/core/handlers/base.py", line 164, in get_response
    response = response.render()
  File "django/template/response.py", line 158, in render
    self.content = self.rendered_content
  File "django/template/response.py", line 135, in rendered_content
    content = template.render(context, self._request)
  File "django_jinja/backend.py", line 64, in render
    return self.template.render(context)
  File "jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "./yellow/our_template.html", line 83, in block "main_content"
    {{ render_company(company_name, switch_is_active("ourswith", request.user)) }}
  File "yellow/templatetags/tags.py", line 137, in switch_is_active
    return gargoyle.is_active(switch_slug, *instances)
  File "gargoyle/manager.py", line 58, in is_active
    switch = self[key]
  File "gargoyle/manager.py", line 34, in __getitem__
    return SwitchProxy(self, super(SwitchManager, self).__getitem__(key))
  File "modeldict/base.py", line 23, in __getitem__
    self._populate()
  File "modeldict/base.py", line 168, in _populate
    elif self.local_cache_has_expired():
  File "modeldict/base.py", line 108, in local_cache_has_expired
    recheck_at = self._last_checked_for_remote_changes + self.timeout

Seems to be a concurrency issue in the function local_cache_has_expired

105.  if not self._last_checked_for_remote_changes:
106.      return True  # Never checked before
107.
108.  recheck_at = self._last_checked_for_remote_changes + self.timeout
109.  return time.time() > recheck_at

We use:

django  1.8.4
gargoyle    0.11.0
Fluxx commented 8 years ago

What is the actual exception that is being thrown?

adamchainz commented 8 years ago

Hi, the concurrency issue has been fixed in our fork django-modeldict-yplan (in this commit), please check it out at https://github.com/YPlan/django-modeldict .

martino commented 8 years ago

Thank you!

adamchainz commented 8 years ago

Forgot to say: we're also maintaining nexus and gargoyle - pip install nexus-yplan and gargoyle-yplan.