Skip to content

Make account deletion cleanup durable and observable #8405

Closed

Description

@Git-on-my-level

Context

PR #8393 extracts account deletion/export logic into user data services. Its review comments were resolved locally, but one review thread surfaces a broader architecture smell: account deletion cleanup is treated like best-effort post-processing even though users are told deletion has started and the workflow removes data across Firebase, Firestore, vector stores, storage, and Twilio.

Evidence

  • In PR [codex] Extract user data services #8393, cubic identified an inline P1 on backend/services/users/account_deletion.py that the original implementation dispatched cleanup with threading.Thread(..., daemon=True).start(). The comment called out that shutdown/redeploy could terminate the wipe mid-flight, leaving user data partially deleted after reporting deletion started: [codex] Extract user data services #8393 (comment)
  • The PR-local fix replaced the daemon thread with submit_with_context(postprocess_executor, background_wipe_user_data, uid) in backend/services/users/account_deletion.py.
  • backend/utils/executors.py documents postprocess_executor as best-effort post-processing, not durable job execution, and its shutdown path uses executor.shutdown(wait=False, cancel_futures=True). That is a meaningful improvement over a daemon thread, but it still does not give account deletion durable enqueue, retry, status tracking, or recovery across deploy/process shutdown.
  • The same PR also had review findings around GDPR/CCPA export completeness (backend/services/users/data_export.py 10,000-record caps and pagination termination). Those were fixed in the PR, but together they show that account export/deletion paths need explicit compliance-grade guarantees rather than incidental background behavior.

Proposed follow-up scope

  • Move account deletion cleanup from the best-effort postprocess_executor path to a durable mechanism, e.g. Cloud Tasks / a persisted job record / another backend queue already used by this repo.
  • Make the deletion operation idempotent and safe to retry across all external stores: Twilio caller IDs, vector DB records, recordings/storage, and Firestore user data.
  • Persist deletion status and last error so support/ops can identify and retry partial wipes.
  • Return success to the API caller only after the durable job is created, or make the endpoint block through the full wipe if product requirements prefer synchronous deletion.
  • Add tests that simulate worker/process shutdown or enqueue failure and assert that account deletion is not silently acknowledged without durable follow-through.

Non-goals

Oracle follow-up refinement - 2026-06-27

The PR #8393 oracle review agreed this belongs outside the refactor PR, but recommended that the durable deletion saga explicitly cover the whole account-lifecycle workflow, not only post-auth cleanup. Include these steps in the long-term design:

  • Persist deletion feedback and requested reason/details as part of the deletion job.
  • Cancel Stripe subscriptions with idempotent retry/status tracking, or record a retryable billing-cancellation failure.
  • Revoke/delete Firebase Auth, treating already-missing users as completed while surfacing unexpected auth failures.
  • Then run Twilio, vector DB, recording/storage, and Firestore cleanup as idempotent retryable steps.
  • Return API success only after the deletion request is durably recorded and the worker job is durably enqueued.

Activity

  1. added
    p2
    backend
    memory
    p1
    and removed
    p2
    on Jul 2, 2026
  2. added a commit that references this issue on Jul 6, 2026
    edbe51e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendmemoryp1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions