Skip to content

perf(user): drain GDPR deletion batches within a claim - #5368

Merged
eshurakov merged 5 commits into
mainfrom
eshurakov/nimble-condor
Aug 19, 2026
Merged

perf(user): drain GDPR deletion batches within a claim#5368
eshurakov merged 5 commits into
mainfrom
eshurakov/nimble-condor

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

Speed up GDPR teardown for users with large CLI session and usage-prefix histories, and show real progress in the admin queue.

A production user with 4k+ CLI sessions was deleting ~10/min (~7h) because each cron claim processed one leaf batch of 10 and then yielded. Usage-prefix scrubbing had the same one-page-per-claim shape, so already-clean pages looked idle.

  • CLI v2 now DELETEs each leaf batch in parallel and keeps draining batches until the cron time reserve is gone. Successful sibling deletes are counted even if another leaf in the same batch 409s.
  • Usage-prefix scrubbing keeps scanning already-clean pages in the same claim and only yields after a dirty page or when the time budget is gone.
  • Persist scanned_count next to processed_count so the admin queue can show “80 scrubbed · 49000 scanned” instead of looking stuck.

No SQL migration: scanned_count is an optional JSON field.

Verification

  • pnpm --filter web test -- src/lib/user/deletion-queue/handlers/cli-v2.test.ts --runInBand
  • pnpm --filter web test -- src/lib/user/deletion-queue/handlers/usage-prompt-prefixes.test.ts --runInBand
  • pnpm --filter web test -- src/app/admin/deletion-queue/deletion-queue-format.test.ts --runInBand
  • No new local admin-queue run against a 4k-session user; retry the CLI sessions step after deploy.

Visual Changes

Admin deletion-queue progress tiles and activity rows now show step counts (N deleted / N scrubbed · M scanned) and unlock later groups only after earlier groups finish.

Reviewer Notes

Per-session session-ingest DELETE is unchanged (leaf-only, 409 on non-leaf). Parallelism is inside one claimed batch of 10.

CLI v2 deletes leaf sessions in parallel and keeps draining batches
until the cron reserve is gone. Usage-prefix scrubbing skips already
clean pages in the same claim and records scanned_count so the admin
queue shows real progress.
Keep parsed progress narrowed across the scan loop and allow null
prefixes in the already-clean page fixture.
Persist processed_count on retry, rate-limit, and needs-attention so a
partial leaf batch is not lost if a sibling DELETE fails.
Assert CLI leaf-batch progress survives a later 500, and that retry
and needs-attention dispositions write processed_count onto the step.
withProgress cannot spread onto DeletionHandlerManualAction.
@kilo-code-bot

kilo-code-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the GDPR claim-drain changes across CLI v2 parallel deletes, usage-prefix clean-page scanning, progress persistence, and admin queue display; no high-confidence bugs in changed code.

Files Reviewed (12 files)
  • apps/web/src/app/admin/deletion-queue/[id]/DeletionQueueDetailContent.tsx
  • apps/web/src/app/admin/deletion-queue/deletion-queue-format.test.ts
  • apps/web/src/app/admin/deletion-queue/deletion-queue-format.ts
  • apps/web/src/lib/user/deletion-queue/deletion-outcomes.test.ts
  • apps/web/src/lib/user/deletion-queue/deletion-outcomes.ts
  • apps/web/src/lib/user/deletion-queue/deletion-types.ts
  • apps/web/src/lib/user/deletion-queue/handlers/cli-v2.test.ts
  • apps/web/src/lib/user/deletion-queue/handlers/cli-v2.ts
  • apps/web/src/lib/user/deletion-queue/handlers/usage-prompt-prefixes.test.ts
  • apps/web/src/lib/user/deletion-queue/handlers/usage-prompt-prefixes.ts
  • apps/web/src/routers/admin/user-deletion-queue-router.ts
  • packages/db/src/schema-types.ts

Reviewed by grok-4.6 · Input: 339.2K · Output: 31.4K · Cached: 780.4K

Review guidance: REVIEW.md from base branch main

@eshurakov
eshurakov merged commit 2090449 into main Aug 19, 2026
48 checks passed
@eshurakov
eshurakov deleted the eshurakov/nimble-condor branch August 19, 2026 11:36
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.

2 participants