Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
#710: Restore Entities, Purge Entities, ability to see deleted Entities #1349
#710: Restore Entities, Purge Entities, ability to see deleted Entities #1349
Changes from 4 commits
7b38616
90f985c
0713461
0f5d716
813fc25
5be8b33
a5a6fde
60c06fd
41d2f11
85bdd0c
c9aab19
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should throw this instead
But I also noticed that if you try to reuse a soft-deleted UUID, it also has
Problem.user.uniquenessViolation
instead ofProblem.user.entityDeleted
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have introduced
entityUniquenessViolationWithDeleted
- please suggest a shorter name.I think we should not return 404 during create entity where there is/was entity with the same UUID is soft-deleted or purged. So for create I am returning 409 and for update 404.
Let me know what do you think about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean about the 409 vs the 404. Also that other
entityDeleted
problem doesn't have a very descriptive name; it's more likeentityNotFoundDeleted
. It's also only used in one case where a submission tries to update something about an entity and the entity has been deleted.I can't really think of a shorter name than
entityUniquenessViolationWithDeleted
.entityConflictDeleted
? Nah, what you have, even though it is long, is clear.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this should say given that the existing message mentions a single entity uuid.
"The entity with UUID (uuid1, uuid2, uuid3,...) has been deleted."
But it might be better than what it currently returns, e.g. this response json:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated with
entityUniquenessViolationWithDeleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should move this to central place, this is present in three file at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, maybe it could be injected in the container around here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved it to a separate constant file instead of populating it in the container. I find it easier to access that way. Let me know if you think it is better to have them in the container, I will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The separate constant file looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the source is a bulk source, deleting this for one purged entity doesn't seem right and also leads to FK violation.
My thoughts are either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am leaning towards adding
AND entity_def_sources.type = 'submission'
Here's a test where entities are uploaded in bulk but not all are deleted/purged:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I have just kept source for the entities created via bulk upload.
Maybe in future, we can remove the orphan sources where all the entities created by them are purged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this backlog is working correctly, this table will probably be empty and we don't have to delete anything here.
The only thing I'd want to see tested would be if you delete and purge while something is in the backlog, the worker that tries to force-process the backlog doesn't have a problem. But I don't think it should... I think it'll just fail to find the entity it's looking for and it'll quietly skip it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take this back... leave this bit in. I tried altering the test
should purge submission backlog for entities
where this query didn't delete from the backlog and an update entity submission was left in the backlog. When the backlog was later processedawait Entities.processBacklog(true);
it led to a submission processing error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should catch UUID conflict error if it is not provided in the request body (means backend has generated it and there is a collision) and generate a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea! I'm not sure if it's necessary to implement or how exactly you'd test it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it again, probability of collision is so low that it doesn't worth the effort. I would blame the luck of that user who fall into this case 🙈