Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32036 closed Bug (invalid)

stack overflow on admin save

Reported by: Riccardo Magliocchetti Owned by: nobody
Component: Uncategorized Version: 3.0
Severity: Normal Keywords: threading
Cc: Riccardo Magliocchetti Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Found this splat on gunicorn logs, this happen sometimes on model deletion from admin:

Fatal Python error: Cannot recover from stack overflow.

Current thread 0x00007f79b9a46740 (most recent call first):
  File "/usr/lib/python3.6/asyncio/events.py", line 691 in get_event_loop
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/asgiref/sync.py", line 334 in get_current_task
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/asgiref/local.py", line 54 in _get_context_id
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/asgiref/local.py", line 83 in _get_storage
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/asgiref/local.py", line 100 in __getattr__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/utils.py", line 201 in __getitem__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1181 in build_lookup
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1315 in build_filter
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1385 in _add_q
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1377 in _add_q
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1354 in add_q
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 923 in _filter_or_exclude
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 904 in filter
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 404 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 153 in get_object
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 186 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 151 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 655 in get_instance_value_for_fields
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 635 in get_local_related_value
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 174 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 151 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 152 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 655 in get_instance_value_for_fields
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 635 in get_local_related_value
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 174 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 151 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 152 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 655 in get_instance_value_for_fields
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 635 in get_local_related_value
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 174 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 151 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 152 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 655 in get_instance_value_for_fields
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related.py", line 635 in get_local_related_value
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 174 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 151 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  File "/home/deploy/foo.bar.net/project/subscriber/models.py", line 152 in __init__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 512 in from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 75 in __iter__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 1261 in _fetch_all
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 258 in __len__
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query.py", line 411 in get
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/base.py", line 627 in refresh_from_db
  File "/home/deploy/foo.bar.net/lib/python3.6/site-packages/django/db/models/query_utils.py", line 139 in __get__
  ...

Our code is the following:

class Model(models.Model):
    subscription = models.ForeignKey(Config, on_delete=models.SET_NULL, null=True, blank=True)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # line 151 is the following
        self._prev_subscription_id = self.subscription and self.subscription.subscription_id or None
        self._prev_table_id = self.table_id

This is Python 3.6.9 and Django 3.0.9 with asgiref 3.2.7. I can upgrade asgiref to 3.2.10, I haven't seen anything related on django 3.1 release notes.

Change History (2)

comment:1 by Carlton Gibson, 4 years ago

Resolution: invalid
Status: newclosed

Please don't use the issue tracker as a secondary support channel. See TicketClosingReasons/UseSupportChannels

comment:2 by Riccardo Magliocchetti, 4 years ago

Cc: Riccardo Magliocchetti added

Hello, I understand you are busy but I'm not asking to debug my code :) This is a Python stack overflow of what looks like some recursion around django related models code. Since this does not happen everytime and it has the django thread local storage code in the stack strace it's pretty scary stuff (to me at least) :)

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