-
Notifications
You must be signed in to change notification settings - Fork 87
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
bug: propagate deletion of parent PIDs properly #1864
base: master
Are you sure you want to change the base?
Conversation
c599d45
to
d83ceaa
Compare
|
||
@shared_task(ignore_result=True) | ||
def cleanup_parent_pids(record): | ||
"""Clean up parent PIDs which could not be deleted by the service.""" |
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.
Very minor: the comment assumes that we are calling this task only from a specific service method.
Could you improve it to explain what is happening here instead?
Looks like that it will discard all drafts if there is no other published record?
What happens if there are no drafts? (well, probably the parent should not exist)?
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.
Noted, however just fyi that this doesn't work on drafts
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.
Noted, however just fyi that this doesn't work on drafts
OK, it makes sense, can you make it explicit it then? e.g. assert that it is a record, and fail if it is a draft?
I see that it is handled in the code ;)
cf7d61e
to
38f5e94
Compare
def cleanup_parent_pids(recid): | ||
"""Clean up parent PIDs.""" | ||
record_cls = current_rdm_records.records_service | ||
record = record_cls.pid.resolve(recid) |
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 understand that this task is initiated when the recid
is deleted right? If so, wouldn't that resolve fail?
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.
fixed :)
7c03d27
to
a7804f6
Compare
a7804f6
to
dca0674
Compare
# We're sending a task in case there is a race condition with two | ||
# versions being deleted at the same time to ensure that we have | ||
# consistent database state | ||
self.uow.register(TaskOp(cleanup_parent_pids, record["id"])) |
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.
It looks like that the if
above is copy/pasted in the celery task.
Does it make sense to completely remove the if
condition here and simply call:
self.uow.register(TaskOp(cleanup_parent_pids, record["id"]))
?
This is a bit confusing.
Can you please rebase after @alejandromumo fixed the tests? It should solve the CI failure. |
❤️ Thank you for your contribution!
Relies on #1810 being merged first
Close #1863
Description
Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
Frontend
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that: