Skip to content

feat(soft-delete): warn at startup when the purge beat entry is missing - #42641

Draft
mikebridge wants to merge 1 commit into
apache:masterfrom
mikebridge:sc-111918-purge-beat-warning
Draft

feat(soft-delete): warn at startup when the purge beat entry is missing#42641
mikebridge wants to merge 1 commit into
apache:masterfrom
mikebridge:sc-111918-purge-beat-warning

Conversation

@mikebridge

Copy link
Copy Markdown
Contributor

SUMMARY

Operators who redefine CeleryConfig in superset_config.py — instead of subclassing or merging the default — silently lose beat-schedule entries. For the soft-delete purge task (deletion_retention.purge_soft_deleted) this failure mode is invisible until it matters: archived objects accumulate forever instead of purging after the retention window.

This generalizes the existing startup check for the version-history retention entry (_warn_if_retention_beat_missing) to also cover the purge task:

  • The version-history entry is checked unconditionally, as before (shadow rows written by prior deploys keep ageing even when capture is off).
  • The purge entry is checked only when the SOFT_DELETE feature flag resolves on at the config level (DEFAULT_FEATURE_FLAGS merged with FEATURE_FLAGS, matching FeatureFlagManager.init_app order). The purge task itself no-ops while the flag is off, so a missing entry is only actionable once soft delete is live. Flags supplied dynamically via GET_FEATURE_FLAGS_FUNC are deliberately not consulted — this is a configuration-only startup diagnostic.

All four documented CELERY_CONFIG shapes (None, class/module, dict, dotted string) behave as before, and matching is by each entry's task value, not the schedule key, so a correctly-scheduled task under a renamed key does not warn.

This is groundwork for eventually enabling SOFT_DELETE by default: the warning must exist before any release ships with soft delete on, so deployments with hand-rolled Celery configs learn about the missing purge entry from the deploy log rather than from unbounded growth.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — log-only change. New warning text:

soft-delete: CELERY_CONFIG.beat_schedule is missing the 'deletion_retention.purge_soft_deleted' entry — archived objects will never be purged and will accumulate indefinitely. Either inherit from the default CeleryConfig or add the entry to your override.

TESTING INSTRUCTIONS

  1. pytest tests/unit_tests/initialization_test.py -k RetentionBeatWarning — 12 tests: 7 pre-existing plus 5 new covering the purge entry (warn when flag on + entry missing, silent when flag off, FEATURE_FLAGS override beats the default, silent when both entries present, renamed-key parity).
  2. Manually: set FEATURE_FLAGS = {"SOFT_DELETE": True} and a CELERY_CONFIG class without the purge entry in superset_config.py; start the app; the warning above appears once at startup. Restore the default CeleryConfig; no warning.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SOFT_DELETE (the new warning only fires when it resolves on)
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

Operators who redefine CeleryConfig in superset_config.py instead of
subclassing or merging the default silently lose the
deletion_retention.purge_soft_deleted beat entry: archived objects then
accumulate forever instead of purging after the retention window.

Generalize the existing version-history beat check to also cover the
purge task, gated on SOFT_DELETE resolving on at the config level
(the purge task itself no-ops while the flag is off, so a missing
entry is only actionable once soft delete is live).

This is a precondition for flipping the SOFT_DELETE default
(sc-111918): the warning must be in place before any release ships
with soft delete on by default.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.44%. Comparing base (7d2b184) to head (a0c35eb).

Files with missing lines Patch % Lines
superset/initialization/__init__.py 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42641      +/-   ##
==========================================
- Coverage   65.44%   65.44%   -0.01%     
==========================================
  Files        2810     2810              
  Lines      159362   159366       +4     
  Branches    36372    36373       +1     
==========================================
- Hits       104301   104300       -1     
- Misses      53019    53022       +3     
- Partials     2042     2044       +2     
Flag Coverage Δ
hive 38.09% <50.00%> (+<0.01%) ⬆️
mysql 57.82% <50.00%> (-0.01%) ⬇️
postgres 57.86% <50.00%> (-0.01%) ⬇️
presto 39.98% <50.00%> (+<0.01%) ⬆️
python 59.25% <50.00%> (-0.01%) ⬇️
sqlite 57.49% <50.00%> (-0.01%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant