Skip to content

Update delete task to skip over already deleted objects - #7930

Open
gerrod3 wants to merge 1 commit into
pulp:mainfrom
gerrod3:fix/7910-general-multi-delete-does-not-exist
Open

Update delete task to skip over already deleted objects#7930
gerrod3 wants to merge 1 commit into
pulp:mainfrom
gerrod3:fix/7910-general-multi-delete-does-not-exist

Conversation

@gerrod3

@gerrod3 gerrod3 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Also added delete results output to the tasks.

fixes: #7910
Generated by: cursor-grok-4.5

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

@gerrod3 gerrod3 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This only covers the case where the user dispatches multiple delete tasks on the same object. Every N+1 task will no result in a no-op instead of error. However, there are still many scenarios where the delete can fail that isn't caught with this change. Here are some AI thought of:

Business-rule / hook failures

RepositoryVersion: last complete version → APIException
RepositoryVersion: protected version → BEFORE_DELETE raises
RepositoryVersion: squash didn’t clear memberships → RuntimeError
Other BEFORE_DELETE hooks (domains, remotes, etc.)

Integrity / relation failures

ProtectedError / RestrictedError when related rows block the delete (PROTECT/RESTRICT), e.g. ContentArtifact → Artifact, AlternateContentSource → Remote, RepositoryContent.version_added/removed → RepositoryVersion
Other DB integrity errors from cascade cleanup

Concurrency / ordering

Object (or a later multi-delete target) removed between get/cast and delete
In general_multi_delete, deleting A cascades away B still in the list → later B.delete() can fail or delete nothing
Deadlocks / lock waits (notably RepositoryVersion’s select_for_update)

Operational

DB timeouts, disconnects, OOM on large cascade trees
Nested work inside overrides (cache, bulk _raw_delete, etc.) raising unexpectedly
general_multi_delete specifically

One failing delete() aborts the outer transaction.atomic(), so earlier deletes in that batch roll back.

Usually not task failures

Artifact file removal runs on transaction.on_commit, so storage errors there don’t fail the delete call itself.

Comment on lines +116 to +120
log.info(
"Skipping delete of %s pk=%s; it no longer exists.",
model.__name__,
instance_id,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Some questions about logging:

  1. What is our current policy of using gettext? Should we still be wrapping log statements inside it?
  2. Does something like this deserved to be logged if we put it in the task output? I didn't tell the AI to remove the logs after adding the output, but my general question is what things are important enough that they need to be logged?

for model_label, count in instance.delete()[1].items():
counts[model_label] += count
output.update(counts)
return dict(output)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Task outputs can be anything as long as they are serializable, correct?

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.

general_multi_delete raises bare DoesNotExist, triggering deprecation warning it can never fix

1 participant