Skip to content

Instantly share code, notes, and snippets.

@dannon
Created March 31, 2026 11:33
Show Gist options
  • Select an option

  • Save dannon/0d7c42f8a5ecaebeeca3c4ed79151b13 to your computer and use it in GitHub Desktop.

Select an option

Save dannon/0d7c42f8a5ecaebeeca3c4ed79151b13 to your computer and use it in GitHub Desktop.
Triage: #22312 - History purge does not cascade to dataset collections

Triage: #22312 -- History purge does not cascade to dataset collections

Classification: Bug Severity: Medium Effort: Small

Root Cause

The HistoryManager.purge() method in lib/galaxy/managers/histories.py (line 289) only cascades to HDAs, completely ignoring HDCAs:

  1. Non-celery path (lines 308-310): loops over item.datasets (HDAs), never touches item.dataset_collections
  2. Celery path (purge_history_datasets in lib/galaxy/celery/tasks.py, lines 126-177): bulk UPDATE targets only HistoryDatasetAssociation table
  3. super().purge() (line 313): just marks the History row itself as purged via PurgableManagerMixin -- no child content awareness

The individual content purge path in history_contents.py (lines 1470-1476) handles HDCAs correctly via DatasetCollectionManager.delete() -- this is specifically a gap in the history-level cascade.

Proposed Fix

1. Non-celery path (lib/galaxy/managers/histories.py)

After the HDA loop (line 310), add:

for hdca in item.dataset_collections:
    if not hdca.deleted:
        hdca.deleted = True

2. Celery path (lib/galaxy/celery/tasks.py)

After the HDA bulk update (~line 166), add a bulk UPDATE for HistoryDatasetCollectionAssociation setting deleted=True.

Note: HDCAs have no purged column -- only deleted and visible. Setting deleted=True is sufficient since the underlying HDA purging is already handled by the existing HDA loop.

Related Issues

  • #14966 (closed) -- "(Permanently) deleting datasets has no (immediate) effect"
  • PR #13935 (merged) -- "Bulk operations: more API tests & fixes"

Files Involved

  • lib/galaxy/managers/histories.py -- HistoryManager.purge() (line 289)
  • lib/galaxy/celery/tasks.py -- purge_history_datasets() (line 126)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment