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

bug: propagate deletion of parent PIDs properly #1864

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

carlinmack
Copy link
Contributor

❤️ Thank you for your contribution!

Relies on #1810 being merged first
Close #1863

Description

Please describe briefly your pull request.

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:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@carlinmack carlinmack changed the title Propagate del bug: propagate deletion of parent PIDs properly Oct 31, 2024
@ntarocco ntarocco self-assigned this Nov 1, 2024
@carlinmack carlinmack changed the base branch from master to validate-affiliatons November 1, 2024 13:06
@carlinmack carlinmack changed the base branch from validate-affiliatons to master November 1, 2024 13:06
invenio_rdm_records/requests/user_moderation/utils.py Outdated Show resolved Hide resolved

@shared_task(ignore_result=True)
def cleanup_parent_pids(record):
"""Clean up parent PIDs which could not be deleted by the service."""
Copy link
Contributor

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)?

Copy link
Contributor Author

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

Copy link
Contributor

@ntarocco ntarocco Nov 6, 2024

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 ;)

@ntarocco ntarocco assigned carlinmack and unassigned carlinmack Nov 1, 2024
@carlinmack carlinmack force-pushed the propagate-del branch 4 times, most recently from cf7d61e to 38f5e94 Compare November 12, 2024 08:55
invenio_rdm_records/services/pids/tasks.py Outdated Show resolved Hide resolved
invenio_rdm_records/services/pids/tasks.py Outdated Show resolved Hide resolved
def cleanup_parent_pids(recid):
"""Clean up parent PIDs."""
record_cls = current_rdm_records.records_service
record = record_cls.pid.resolve(recid)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed :)

# 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"]))
Copy link
Contributor

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.

@ntarocco
Copy link
Contributor

Can you please rebase after @alejandromumo fixed the tests? It should solve the CI failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propagating record deletions to DataCite properly
3 participants