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

Allow orphan cleanup of draft distributions. #3979

Merged
merged 1 commit into from
Jun 23, 2023
Merged

Conversation

jastraat
Copy link
Contributor

@jastraat jastraat commented Jun 21, 2023

In sites where datasets and their referenced distributions are all created as draft nodes (like PDC), we've seen a build up of orphan_reference_processor queue items.

This is because prior to this PR, the MetastoreService would only ever retrieve published node revisions - even when getting an orphaned distribution for cleanup.

Since many of the distribution nodes were never published (due to initially being created as a draft) this results in "Error retrieving metadata: distribution {$uuid} not found." being thrown for all distributions being cleaned up that were never published.

This PR adds an optional boolean parameter to MetastoreService::get() to allow it to retrieve unpublished distributions when it is called by cleanResourceMapperTable().

To recreate in a vanilla DKAN site:

  1. Change the default moderation state to "draft" on /admin/config/workflow/workflows/manage/dkan_publishing
  2. Create a new draft dataset.
  3. ddev drush cron to import the datastore
  4. Confirm that a new datastore table was created and there is a draft dataset with a corresponding draft distribution.
  5. Delete the dataset
  6. ddev drush cron to run the orphan_reference_processor
  7. Will get the following error "[error] Drupal\metastore\Exception\MissingObjectException: Error retrieving metadata: distribution [distribution uuid] not found. in Drupal\metastore\Storage\Data->retrieve() (line 190 of /var/www/html/docroot/modules/contrib/dkan/modules/metastore/src/Storage/Data.php)."

To confirm this patch fixes the error, apply the patch, follow the steps above, and do not receive an error. The resource file directory and datastore table are also deleted successfully.

@janette janette merged commit 5b4d039 into 2.x Jun 23, 2023
11 checks passed
@janette janette deleted the orphan_processor_drafts branch June 23, 2023 21:42
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.

None yet

2 participants