Skip to content

fix(deletion-retention): dedupe repeated blocked audits - #42863

Open
mikebridge wants to merge 2 commits into
apache:masterfrom
mikebridge:sc-115343-dedupe-purge-audit
Open

fix(deletion-retention): dedupe repeated blocked audits#42863
mikebridge wants to merge 2 commits into
apache:masterfrom
mikebridge:sc-115343-dedupe-purge-audit

Conversation

@mikebridge

@mikebridge mikebridge commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

Deduplicate consecutive scheduled retention audits that remain blocked for the same entity while preserving the write-ahead audit invariant. The scheduled purge still writes a provisional pending record before evaluating the cascade, but removes only that current provisional record when its unambiguous, strictly older scheduled predecessor is already blocked.

The change preserves completed audit history, retains evidence on ambiguous ordering or persistence uncertainty, and leaves force-purge auditing independent. It also adds suppression/fallback metrics and a composite predecessor-lookup index.

Shortcut: SC-115343.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable; backend audit behavior only.

TESTING INSTRUCTIONS

source ~/venv/superset/bin/activate
pytest -q \
  tests/integration_tests/deletion_retention/audit_tests.py \
  tests/integration_tests/deletion_retention/purge_tests.py \
  tests/integration_tests/deletion_retention/force_purge_tests.py

Expected: 61 tests pass.

The migration was verified on an isolated SQLite metadata database with an upgrade, downgrade to c4a1b8e2d739, and re-upgrade. EXPLAIN QUERY PLAN selected ix_purge_audit_log_retention_predecessor for the predecessor lookup. Changed-file pre-commit passes, including MyPy, Ruff, and Pylint.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

The migration adds one non-unique index to purge_audit_log. The table and scheduled purge were introduced recently, and each normal run processes at most 500 eligible entities per batch, so existing deployments are expected to have audit histories on the order of thousands—not millions—of rows unless the task has been invoked unusually often. At that expected size, a normal index build should complete quickly and the portability of Superset’s transactional migration helper is preferable to a PostgreSQL-only concurrent-index path. Runtime remains proportional to the actual audit-table row count. PostgreSQL may block writes and MySQL may hold a metadata lock during creation; operators with unexpectedly large audit tables should measure the table and schedule the migration in a maintenance window. No application downtime is otherwise expected. The downgrade removes only this index.

@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 9ef7504
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a74eff8f5ef4c0008918459
😎 Deploy Preview https://deploy-preview-42863--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review bito-code-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Agent Run #8e2f54

Actionable Suggestions - 2
  • superset/tasks/deletion_retention.py - 1
  • superset/migrations/versions/2026-08-06_18-00_b8d2f4a6c901_index_purge_audit_predecessor.py - 1
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • tests/integration_tests/deletion_retention/audit_tests.py - 1
Review Details
  • Files reviewed - 7 · Commit Range: 9ef7504..9ef7504
    • superset/commands/deletion_retention/audit.py
    • superset/migrations/versions/2026-08-06_18-00_b8d2f4a6c901_index_purge_audit_predecessor.py
    • superset/models/purge_audit_log.py
    • superset/tasks/deletion_retention.py
    • tests/integration_tests/deletion_retention/audit_tests.py
    • tests/integration_tests/deletion_retention/force_purge_tests.py
    • tests/integration_tests/deletion_retention/purge_tests.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/tasks/deletion_retention.py

@richardfogaca richardfogaca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Richard's agent here:

Blocking: _retention_predecessor() selects one row ordered only by created_on, which is not a unique sequence. Multiple prior scheduled outcomes can share the newest timestamp; if a tied blocked row is selected while another tied row is failed or confirmed, the current audit is suppressed even though the preceding outcome is ambiguous.

Could we retain the current row whenever the maximum predecessor timestamp is tied—or introduce a durable ordering key—and cover tied blocked plus non-blocked predecessors with a regression test?

Reviewed at 6f6c61e. The current provider status exposes only documentation-preview checks, not the advertised backend test and migration validation.

@bito-code-review

bito-code-review Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b3e811

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 9ef7504..6f6c61e
    • superset/migrations/versions/2026-08-06_18-00_b8d2f4a6c901_index_purge_audit_predecessor.py
    • tests/integration_tests/deletion_retention/audit_tests.py
    • tests/integration_tests/deletion_retention/purge_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

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.

3 participants