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

Handle deleted entities / not_found errors #874

Closed
TheSlimvReal opened this issue Jul 5, 2021 · 5 comments
Closed

Handle deleted entities / not_found errors #874

TheSlimvReal opened this issue Jul 5, 2021 · 5 comments
Labels
Type: Refactoring / Technical Enh. Technical Enhancement without changes for the user

Comments

@TheSlimvReal
Copy link
Collaborator

TheSlimvReal commented Jul 5, 2021

issue summary

As we did not implement #220 from the beginning, we do have a number of invalid references and outdated docs in the database. These cause errors in our logs and sometimes might even show up in lists.
We should implement a way to clean this up and handle such exceptions more smoothly, without triggering errors in our monitoring.

Issues are, for example:

  • if a Child was deleted, ChildSchoolRelation entities of it are not deleted and still floating around the db
  • if a Child was deleted, its id is still referenced in some Note or RecurringActivity entities, which show up as errors in the logs

Possible approach:

  • write an API endpoint (to be triggered manually by admin) to detect dead references and remove such ids from affected entities

original comment

When deleting an entity (e.g. a child) the ID of this child might be used in other entities (e.g. in ChildSchoolRelations or notes). This eventually will throw error messages when the according school or note is viewed.

In general, deleting should only happen, when a child is accidentally created or needs to be removed from the system completely. In this cases, also all the foreign keys should be removed as well (all the mentions of the ID in other entities).

In other cases, where the child does only not participate in the system anymore, the dropout system should be used in order to keep the information available in the system. This way, nothing will be deleted.

What are your thoughts about this topic? Currently we have a lot of error messages regarding deleted children which are very difficult to solve.

@sleidig
Copy link
Member

sleidig commented Jul 17, 2023

Another idea we have discussed right now to avoid the "not_found" errors when an entity was deleted without cascading delete:
catch these cases in the app and display a "record deleted" in the UI without throwing the error in console and sentry.

@sleidig sleidig moved this from Triage to Priority (Core Team) in All Tasks & Issues Sep 18, 2023
@sleidig sleidig changed the title Handle deleted entities Handle deleted entities / not_found errors Sep 21, 2023
@sleidig
Copy link
Member

sleidig commented Sep 21, 2023

I am refocusing this issue on the topic of handling errors of existing broken references. Fixing the issue of generating these when deleting an entity is the topic of #220

@sleidig sleidig moved this from Priority (Core Team) to In Progress in All Tasks & Issues Oct 23, 2023
@sleidig sleidig self-assigned this Oct 23, 2023
@sleidig sleidig moved this from In Progress to Priority (Core Team) in All Tasks & Issues Dec 4, 2023
@sleidig sleidig removed their assignment Dec 4, 2023
@sleidig
Copy link
Member

sleidig commented Dec 4, 2023

With the cascading delete functionality in ndb-core, detecting dead references could reuse the same code. Only challenge (if we want to do this in the backend as a migration): This code is not so easily ported to the backend because it relies on the config schema system.

@TheSlimvReal
Copy link
Collaborator Author

TheSlimvReal commented Dec 5, 2023

Should we close this issue as we now delete entities without leaving dead references? I think it is not too much effort to remove existing broken references once they pop up in sentry manually. Haven't seen them in a while.

@sleidig
Copy link
Member

sleidig commented Dec 5, 2023

Fair enough. As this is not trivial to implement, let's close it here. Please flag cases from Sentry in our internal chat and let us clean these up on a mission towards zero Sentry errors!

@sleidig sleidig closed this as completed Dec 5, 2023
@github-project-automation github-project-automation bot moved this from Priority (Core Team) to Done in All Tasks & Issues Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Refactoring / Technical Enh. Technical Enhancement without changes for the user
Projects
Archived in project
Development

No branches or pull requests

2 participants