-
Notifications
You must be signed in to change notification settings - Fork 10
feat(target): implement soft deletion #860
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
base: main
Are you sure you want to change the base?
Conversation
dadeacf
to
185c280
Compare
See #893 and https://docs.jboss.org/hibernate/orm/7.0/whats-new/whats-new.html#soft-delete-timestamp . It makes sense to use the soft deletion timestamp feature when this becomes available in Quarkus/Panache. It may be worth progressing this WIP PR using the existing |
185c280
to
ce3a7bd
Compare
https://discourse.hibernate.org/t/soft-delete-issue/9839/4 presents another challenge. If SoftDelete entities cannot have OneToOne or ManyToOne lazy-loaded relationships, then we have a real hurdle for our model of a Discovery tree where the leaf nodes are Targets, and all the intermediate DiscoveryNode entities have an optional/lazy/soft-deleted Target. The DiscoveryNodes themselves would also need to be modelled for SoftDelete, but they form a recursive structure since each node has an optional parent node reference and a list of child references (to form bidirectional tree links), so the forced eager loading would mean the entire tree must be loaded into memory every single time there is a query for any Target or any DiscoveryNode. |
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
To recreate commits with GPG signature
git fetch upstream && git rebase --force --gpg-sign upstream/main
See #859
Related to #41
Related to #66
Related to #71
Description of the change:
Implements soft-deletion of Target records. When deleted, rather than the actual record being physically deleted from the database, a deleted flag is simply set. This is using a Hibernate feature, so other HQL queries etc. will automatically ignore these soft-deleted entities. Using native queries we can query the table and ignore the deleted flag, or even query for targets that explicitly have been deleted. This allows the data model to retain all of the information we had about what the target was, even after goes offline or is otherwise lost from discovery. This has been a sore point in the API and data model for a long time, but it's particularly relevant here because we may be getting eligible (correctly labelled, or whatever) archived recordings pushed to us from Agent instances that are in the process of shutting down. If we hard delete Targets instead of soft deleting them, then we always have a race condition between batch processing grabbing the Target record to preserve what information we have about the origin of the recording, and the Target deregistering itself or otherwise disappearing. By preserving the Target record and only soft deleting it when the Target disappears we can resolve the race condition, so that it doesn't matter when the batch process starts or finishes - we can always retrieve information about what the source Target is/was.
Current issues:
Motivation for the change:
This change is helpful because users may want to...
How to manually test: