omi icon indicating copy to clipboard operation
omi copied to clipboard

Account deletion is silently broken in prod: Cloud Tasks queue `account-deletion` does not exist, so no wipe has ever been dispatched

Open kodjima33 opened this issue 3 months ago • 1 comments

Production Cloud Tasks queue account-deletion does not exist, so the durable account-deletion path — the design's sole wipe executor — has never dispatched a single task in prod. Accepted deletion requests return {"status":"ok"} to the user and then depend entirely on a reconciler that can only 404, leaving at least one account undeleted for 21 days and burning a permanent retry loop on every backend-listen pod.

Evidence

1. The queue is missing.

$ gcloud tasks queues list --project based-hardware --location us-central1
QUEUE_NAME                 STATE
audio-merge                RUNNING
conversation-finalization  RUNNING
sync-backfill              RUNNING
sync-jobs                  RUNNING

No account-deletion. Prod config points every service at it — backend/deploy/runtime_env/prod.overlay.yaml:15 (ACCOUNT_DELETION_TASKS_QUEUE: account-deletion), backend/charts/backend-listen/prod_omi_backend_listen_values.yaml:93, and Cloud Run backend, backend-sync, backend-sync-backfill, backend-integration all carry ACCOUNT_DELETION_DISPATCH_MODE=cloud_tasks. _enqueue_named_task (backend/utils/cloud_tasks.py:157) resolves projects/based-hardware/locations/us-central1/queues/account-deletion from SYNC_TASKS_PROJECT/SYNC_TASKS_LOCATION.

2. Every dispatch and re-dispatch 404s, continuously.

ERROR:services.users.account_deletion:delete_account reconciliation enqueue failed for <uid>:
404 Queue does not exist. If you just created the queue, wait at least a minute for the queue to initialize.

prod-omi-gke / prod-omi-backend / backend-listen. Oldest entry retrievable is 2026-07-17T11:10:24Z — that is the log-retention floor, not necessarily the start. 6 distinct uids hit it in the last 7 days alone.

3. The OIDC handler has never run. Zero requests to /v1/users/account-deletion-wipes/run on backend-sync (ACCOUNT_DELETION_HANDLER_URL) in the last 7 days of Cloud Run logs. Per backend/AGENTS.md:147, "reconciliation only re-dispatches tasks so the OIDC handler is the sole wipe executor" — that owner has executed nothing.

4. A real user's data is still here 21 days after they asked for deletion. account_deletions/3xaV607v8rOiDlNKzJvItbbZWBF2:

wipe_intent_at   2026-07-26T17:51:51Z
wipe_queued_at   2026-07-26T17:51:51Z
wipe_status      running
wipe_claimed_at  2026-08-16T13:08:29Z   <- 21 days later, still being re-claimed
wipe_failed_at   2026-08-16T13:08:09Z

GET .../documents/users/3xaV607v8rOiDlNKzJvItbbZWBF2 → 200 (document still exists). For contrast, owK3XGRczxcTBPIfb342jsnR3s72 did reach completed and its users/ doc is a 404 — so completion is happening through some path other than the durable one, which is its own problem: the design says exactly one owner may run a destructive wipe.

5. Retry storm. _periodic_deletion_wipe_reconcile (backend/main.py:290) runs every 300s per pod; reconcile_pending_deletion_wipes re-claims the permanently-failing record with no backoff or attempt cap. Observed 30+ claim transactions + error logs per minute against this one uid, 24/7, for at least a month.

Why the fail-closed guard didn't catch it

validate_account_deletion_dispatch_configuration() (backend/utils/cloud_tasks.py:92) asserts the env vars are present, never that the queue exists. Prod started clean and stayed green while the path behind it was 100% dead. A missing-queue 404 on the first enqueue is indistinguishable from a healthy deploy at startup.

Remediation (needs a human — deliberately not done here)

  1. Create the queue, mirroring conversation-finalization: gcloud tasks queues create account-deletion --project based-hardware --location us-central1 --max-attempts=5 --max-concurrent-dispatches=4 --min-backoff=0.1s --max-backoff=3600s
  2. Verify [email protected] holds roles/cloudtasks.enqueuer on it and roles/run.invoker on backend-sync.
  3. Expect an immediate destructive flush: the next reconciler tick will dispatch every backlogged wipe and permanently delete those users' data. That is the correct outcome but it is irreversible, so it wants an owner watching it.
  4. Audit the backlog first — account_deletions where wipe_status != 'completed' — and check how the wipes that did complete were executed, since the handler never ran.
  5. Follow-ups worth their own PRs: a startup/health probe that asserts the configured queue resolves (get_queue) instead of only reading env vars; queue definitions in IaC so a queue can't be missing from an environment; and an attempt cap / backoff in reconcile_pending_deletion_wipes so one poisoned record can't loop forever.

Related: #9760 (the PR that made deletion fail-closed on Cloud Tasks dispatch).

🤖 filed by the hourly desktop bug watchdog — reported, not fixed: creating the queue is an irreversible prod data-deletion action and there is no in-repo IaC to PR.

kodjima33 avatar Aug 16 '26 13:08 kodjima33

I have implemented the code remediation outlined in follow-up #5: capping retry attempts in reconcile_pending_deletion_wipes and adding a dead-letter terminal state (terminal_failed) to permanently stop the 24/7 retry storm and Firestore transaction spam across pods.

Implementation Summary

  1. Configurable Attempt Cap & Dead-Letter Terminal Status:
    • Added DELETION_WIPE_MAX_ATTEMPTS = int(os.getenv('DELETION_WIPE_MAX_ATTEMPTS', '10')).
    • Introduced terminal_failed to _DELETION_WIPE_TERMINAL_STATUSES.
    • Added helper mark_user_deletion_wipe_terminal_failed(uid, reason, error).
  2. Transaction-Level Backoff Guard & Attempt Capping:
    • In _claim_deletion_wipe_txn, capped attempts immediately transition to terminal_failed with terminal_reason='max_attempts_exceeded'.
    • Enforced backoff check inside the Firestore transaction, eliminating multi-pod race conditions that previously bypassed get_pending_deletion_wipes backoff queries.
  3. Eliminated 0-Second Stale Running Loop:
    • Stale running markers with missing wipe_running_at now fall back gracefully to wipe_claimed_at / wipe_queued_at / wipe_intent_at and refuse claims if no timestamp can be determined, eliminating the 0-second re-claim loop.
  4. Reconciler Attempt Capping & Dead-Letter Telemetry:
    • In reconcile_pending_deletion_wipes, records hitting the attempt cap are transitioned to terminal_failed, emit critical telemetry (terminal: True), log a critical alert, and are skipped.
    • If Cloud Tasks enqueue throws (such as 404 Queue missing) and exhausts attempts, it transitions directly to terminal_failed.
  5. Terminal State Protection:
    • _claim_deletion_wipe_task_txn, _mark_user_deletion_wipe_intent_txn, and _mark_user_deletion_billing_failed_txn treat terminal_failed as terminal/non-actionable.

Pull Request: #19987 Verification: 105 passed hermetic unit and service tests (pytest backend/tests/services/users/test_account_deletion.py backend/tests/unit/test_deletion_wipe_retry_backoff.py backend/tests/unit/test_claim_deletion_wipe_txn.py).

Bounty Proposal: $350 – $500 USD Payout address (Base / EVM): 0x496e32ff3851cdb9146223a811e3d4f9218dd954

naufalfx805-source avatar Sep 30 '26 10:09 naufalfx805-source