Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursion error in periodic data removal #2632

Closed
LaurensBurger opened this issue Feb 1, 2023 · 7 comments · Fixed by #2968
Closed

Recursion error in periodic data removal #2632

LaurensBurger opened this issue Feb 1, 2023 · 7 comments · Fixed by #2968
Assignees
Labels
needs-backport Fix must be backported to stable release branch
Milestone

Comments

@LaurensBurger
Copy link
Collaborator

LaurensBurger commented Feb 1, 2023

Product versie / Product version

All

Sentry 321138

RecursionError: maximum recursion depth exceeded while calling a Python object
  File "openforms/data_removal/tasks.py", line 31, in delete_submissions
    successful_submissions_to_delete.delete()
  File "django/db/models/query.py", line 745, in delete
    collector.collect(del_query)
  File "django/db/models/deletion.py", line 295, in collect
    if sub_objs:
  File "django/db/models/query.py", line 284, in __bool__
    self._fetch_all()
  File "django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "django/db/models/query.py", line 69, in __iter__
    obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
  File "django/db/models/base.py", line 515, in from_db
    new = cls(*values)
  File "openforms/submissions/models/submission_step.py", line 134, in __init__
    if not self.form_step_id:
  File "django/db/models/query_utils.py", line 144, in __get__
    instance.refresh_from_db(fields=[field_name])
  File "django/db/models/base.py", line 650, in refresh_from_db
    db_instance = db_instance_qs.get()
  File "django/db/models/query.py", line 431, in get
    num = len(clone)
  File "django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "django/db/models/query.py", line 69, in __iter__
    obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
  File "django/db/models/base.py", line 515, in from_db
    new = cls(*values)
  File "openforms/submissions/models/submission_step.py", line 135, in __init__
    self.form_step = self._load_form_step_from_history()
  File "openforms/submissions/models/submission_step.py", line 141, in _load_form_step_from_history
    history = deepcopy(self.form_step_history)
  File "django/db/models/query_utils.py", line 144, in __get__
    instance.refresh_from_db(fields=[field_name])
  File "django/db/models/base.py", line 650, in refresh_from_db
    db_instance = db_instance_qs.get()
  File "django/db/models/query.py", line 431, in get
    num = len(clone)
  File "django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "django/db/models/query.py", line 69, in __iter__
    obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
  File "django/db/models/base.py", line 515, in from_db
    new = cls(*values)
  File "openforms/submissions/models/submission_step.py", line 134, in __init__
    if not self.form_step_id:
  File "django/db/models/query_utils.py", line 144, in __get__
    instance.refresh_from_db(fields=[field_name])
  File "django/db/models/base.py", line 650, in refresh_from_db
    db_instance = db_instance_qs.get()
  File "django/db/models/query.py", line 431, in get
    num = len(clone)
  File "django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "django/db/models/query.py", line 69, in __iter__
    obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
  File "django/db/models/base.py", line 515, in from_db
    new = cls(*values)
  File "openforms/submissions/models/submission_step.py", line 135, in __init__
    self.form_step = self._load_form_step_from_history()
  File "openforms/submissions/models/submission_step.py", line 141, in _load_form_step_from_history
[...]

Omschrijf het probleem / Describe the bug

Error can be found in Sentry. Originates from delete_submission and can be found in all deployed instances

@LaurensBurger LaurensBurger added bug triage Issue needs to be validated. Remove this label if the issue considered valid. labels Feb 1, 2023
@sergei-maertens
Copy link
Member

Very much related to #2305 and #2135

@sergei-maertens
Copy link
Member

sergei-maertens commented Feb 1, 2023

@joeribekker I'd like to make a case again for snapshotting the entire state/configuration of the form inside the submission so we can get rid of this less-than-optimal historical step configuration workaround, it's unpredictable

@joeribekker joeribekker changed the title Recursion error Recursion error in periodic data removal Feb 24, 2023
@joeribekker joeribekker added this to the Release 2.2.0 milestone Feb 24, 2023
@joeribekker
Copy link
Contributor

@joeribekker I'd like to make a case again for snapshotting the entire state/configuration of the form inside the submission so we can get rid of this less-than-optimal historical step configuration workaround, it's unpredictable

I agree this can be one of the big topics, but seems less urgent than others.

@LaurensBurger
Copy link
Collaborator Author

I'm afraid this bug is causing submissions to not be deleted at all when it occurs, iv'e checked multiple instances and the rules set in the general config don't seem to apply anymore for all instances where this bug occurs.

@joeribekker
Copy link
Contributor

Alright, prio re-evaluated. I need someone to explain to me how this works and @sergei-maertens how much work the state-save means.

@joeribekker
Copy link
Contributor

joeribekker commented Apr 3, 2023

Refinement: Timebox this on 1 day to see if we can have a bandaid fix for this that at least doesn't break the entire task so nothing gets cleaned up. If not possible, we go for the full solution (inform us in the next refinement): Keep the state of forms properly in the submission.

@pi-sigma pi-sigma moved this from Todo to In Progress in Development Apr 3, 2023
@joeribekker joeribekker removed the triage Issue needs to be validated. Remove this label if the issue considered valid. label Apr 4, 2023
pi-sigma added a commit that referenced this issue Apr 5, 2023
pi-sigma added a commit that referenced this issue Apr 5, 2023
pi-sigma added a commit that referenced this issue Apr 5, 2023
@sergei-maertens sergei-maertens added the needs-backport Fix must be backported to stable release branch label Apr 6, 2023
pi-sigma added a commit that referenced this issue Apr 6, 2023
sergei-maertens pushed a commit that referenced this issue Apr 6, 2023
+ preliminary 'fix' by catching the recursion error
@sergei-maertens sergei-maertens moved this from In Progress to Implemented in Development Apr 6, 2023
@sergei-maertens
Copy link
Member

I've found a bandaid fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-backport Fix must be backported to stable release branch
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants