Skip to content

Reduce account deletion latency and report cleanup progress - #223

Merged
devhims merged 1 commit into
mainfrom
fix/account-deletion-latency
Oct 21, 2026
Merged

devhims merged 1 commit into
mainfrom
fix/account-deletion-latency

Conversation

@devhims

@devhims devhims commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Problem / Motivation

Deleting an account could appear stuck for nearly two minutes. Retrying during cleanup incorrectly reported an unfinished billing operation. Conversation cleanup also accumulated network waits by updating trace records and deleting private files one at a time.

What changed

Cleanup now batches revoked trace records and private-file deletions, and processes up to four conversations concurrently. Failed batches retain the records needed for retry. The same idle-conversation fixture with 40 tool calls now needs five remote write/delete requests instead of 122.

The billing gate distinguishes an active deletion from an unresolved checkout. The admin panel shows progress and retries interrupted responses against the same account ID. Explicit billing and cleanup errors remain visible. Existing boolean deletion RPCs remain compatible.

Phase timings identify where future cleanup requests wait. Historical logs cannot establish the exact storage-versus-active-work split for the original slow calls. Investigation details.

%%{init: {"themeVariables": {"signalColor": "#475569", "sequenceNumberColor": "#ffffff"}}}%%
sequenceDiagram
    autonumber
    participant C as Conversation cleanup
    participant D as Database
    participant F as File storage
    alt Before, 40-tool-call fixture
        C->>D: 42 individual writes
        C->>F: 80 individual deletes
    else After
        C->>D: 2 trace batches and 2 summary writes
        C->>F: 1 batch deleting 80 files
    end
Loading

The database and file storage remain; batches replace serial per-record requests.

Tests

All 282 targeted backend tests and 22 web tests pass, including failed-batch recovery, late tool completions and interrupted responses. The platform build, web TypeScript check and generated-documentation check pass.

Deployment notes

Deploy the platform before the web client. No database migration is required. Production deployment and a nonproduction deletion smoke test remain pending.

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
video2ctx-web Ready Ready Preview Oct 21, 2026 3:50pm UTC

devhims commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Review: APPROVE

Reviewed exact head d1d7c6fea969f67427f1c9305d3627d91e6c8742 against 2db474175143c5d7a694b2d6f013a9c9a7279458.

No blocking correctness or security findings. The cleanup changes preserve the important safety properties: started conversation RPCs settle before the deletion fence is released; failed storage batches retain retry state; trace acknowledgments are revision-sensitive; and explicit billing, identity and cleanup errors remain visible rather than being silently retried.

Optional P3: recheck the retry budget after sleeping

web/lib/admin-users.ts:15–18,28–34 checks the deadline before the two-second wait, but not before the next DELETE. If a background tab is suspended past the deadline, resuming it still issues one additional request. An independent fake-timer probe reproduced a second DELETE at t=120,000 after an initial in-progress response. Recheck the deadline before subsequent attempts or after the delay. This is nonblocking: the target ID is unchanged and server-side deletion remains fenced/idempotent. It does not require introducing an in-flight request timeout.

Independent verification

  • Platform unit suite: 2,127 passed, 59 skipped.
  • Web unit suite: 129 passed.
  • Workers integration: 178 passed across runtime/session evidence, plus 22 passed for admin account deletion.
  • Three additional Workers probes passed: failure in the second revocation batch of 65 traces; a newer revocation while a prior D1 batch is pending; and failure in the second R2 deletion batch. Retry state survived, newer revisions were not incorrectly acknowledged, and cleanup completed on retry.
  • Platform TypeScript, generated-documentation check and diff whitespace check passed.
  • All nine reported GitHub checks are green for this head, including dashboard and auth E2E: CI run.

Verification limits / rollout

The failure probes use local Workers/D1/R2 emulation, not actual production failures or latency. I did not independently run browser E2E or a full web build; the remote CI results above are separate evidence. No production account was deleted. The historical incident timing and the exact production speedup are not independently established by this review. Preserve the documented platform-before-web rollout order and perform the nonproduction deletion smoke check before relying on production behavior.

@devhims
devhims merged commit 3d11c12 into main Oct 21, 2026
10 checks passed
@devhims
devhims deleted the fix/account-deletion-latency branch October 21, 2026 15:57

This branch was successfully deployed

1 active deployment
Preview — d1d7c6fe Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant