Designing a Privacy-Safe Deletion Pipeline
I need to create a plan for a privacy-safe deletion pipeline that includes essential components like tombstones, cascading deletes across microservices and data stores, audit trails, and backfills. I’ll outline a step-by-step architecture, incorporating guidelines from GDPR and CCPA, while suggesting strategies for idempotency and eventual consistency. I should address how to manage deletion tokens, derived data, backups, and encryption key deletion. Finally, I’ll ensure there are verification jobs and an audit trail for compliance.Creating a Tombstone Workflow
I need to incorporate a tombstone Time to Live (TTL) and design a workflow diagram that includes failure handling, retries, and dead letter strategies. It's crucial to maintain privacy by storing hashed identifiers rather than personal data. I'll also delineate the difference between using deletion events and an orchestrator, creating a "deletion graph" to map services involved.
For re-creation of a user, I can block resynchronization using tombstones or create new accounts with unique user IDs. Additionally, I’ll ensure that derived data, such as machine learning models, are managed properly, exploring options for pseudonymization and aggregation thresholds.Structuring Backup and Deletion Processes
I need to create a structured plan for managing backups, emphasizing that we can't delete from immutable backups. Key rotation or crypto shredding are options, along with implementing backup restoration filtering. I’ll establish a retention schedule and develop a backfill pipeline to scan existing stores for user identifiers, incorporating a "verification" step as an SQL count check.
It's essential to maintain privacy by auditing without PII and storing hashed IDs with salt. I’ll outline goals, data inventory, components like the deletion API and event bus, and define the detailed flow from request to verification, including tombstone design and cascading delete patterns with an audit trail that captures all pertinent information.Designing Backfills and Verification Processes
For backfills, I need to implement discovery and deletion using a state machine along with rate limiting. Verification jobs will involve online checks for each service, scanning data lakes, and periodically examining search indexes.
I’ll address operational concerns like retries, dead letters, partial failures, and legal holds. I want to give examples like minimal SQL, event schemas, and status tracking while keeping detail moderate to avoid overwhelming complexity. I’ll also highlight challenges, such as user ID mapping and handling multi-tenant environments with multiple identifiers, external vendors, and I’ll format this in markdown for clarity.
Below is a reference architecture and step-by-step build guide for a privacy-safe deletion pipeline that supports tombstones, cascading deletes across services, audit trails, backfills, and verification jobs. It’s designed for eventual consistency in microservices, minimizes PII exposure, and is resilient to retries/failures.
0) Core principles (privacy + reliability)
- Single “subject id”: Use an internal, stable identifier (e.g.,
user_id) as the deletion key everywhere. Avoid email/phone as primary deletion identifiers.
- Data ownership: Each service deletes its own storage. No “central service” directly reaching into others’ databases.
- Idempotency: Every deletion operation must be safe to run multiple times.
- Non-resurrection: After deletion, the system must not re-create data from stale events/backfills/imports.
- Audit without PII: Store only what you need for compliance and operations (timestamps/status/actors), not raw personal data.
- Separation of concerns:
- Orchestration: track lifecycle and coordination
- Execution: each service deletes locally
- Verification: prove deletion happened and stays true
1) Components
A. Deletion API (entrypoint)
Receives requests (GDPR/CCPA, account closure, admin tool), validates authorization, and creates a deletion “case”.
B. Tombstone Registry (global)
A strongly consistent store that records “this subject must be treated as deleted”, used to:
- block sign-in / reactivation flows,
- suppress event processing that would rehydrate data,
- prevent backfills/imports from reintroducing data.
C. Orchestrator (state machine)
Tracks which services must delete data and waits for acknowledgments. Can be event-driven.
D. Message bus + Outbox pattern
Publish deletion events reliably without losing them or publishing twice incorrectly.
E. Per-service deletion workers
Each service consumes deletion events and deletes local data (DB rows, blobs, indexes, caches), then emits an acknowledgment.
F. Audit trail (append-only)
Records request metadata + status transitions + acknowledgments, without storing sensitive content.
G. Backfill deleters
For legacy data or newly discovered tables, scan and delete historically stored data for already-deleted subjects.
H. Verification jobs
Periodically assert “no personal data exists for deleted subjects” across stores/search/warehouse.
2) Tombstones: design and semantics
What a tombstone must do
- Authoritative “do not process” signal for the
subject_id.
- Survive retries and replays (stream reprocessing, ETL rebuilds).
- Be queryable fast (hot-path checks).
Minimal schema (example)
CREATE TABLE deletion_tombstones (
subject_id UUID PRIMARY KEY,
deleted_at TIMESTAMPTZ NOT NULL,
request_id UUID NOT NULL, -- ties to audit case
reason_code TEXT NOT NULL, -- "user_request", "fraud", etc.
legal_basis TEXT NULL, -- optional
hold_until TIMESTAMPTZ NULL, -- if you do delayed hard-delete
status TEXT NOT NULL, -- "ACTIVE" (tombstone in force)
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX ON deletion_tombstones (deleted_at);
Tombstone privacy guidance
- Prefer internal IDs (
subject_id) over emails/phones.
- If you must store external identifiers for matching, store hashed + salted forms and keep salt protected (or store in a separate restricted system).
Where tombstones are enforced
- Auth / account service: block login and token issuance.
- Event consumers: before applying any event for
subject_id, check tombstone and drop/ignore.
- ETL/Reverse ETL: filter out tombstoned subjects.
3) Cascading deletes across services
Step 1: Maintain a “deletion graph”
You need a catalog of which services/data stores hold personal data keyed by subject_id.
Example registry (conceptually):
identity-service: users, sessions, MFA, OAuth grants
payments-service: customer token mappings (and external processor references)
content-service: user posts/comments (may require policy choice: delete vs anonymize)
search: indexes
analytics: warehouse tables + derived datasets
object-store: avatars, uploads
support: tickets (may require partial redaction)
This registry becomes the orchestrator’s checklist.
Step 2: Two robust patterns for cascading deletion
Pattern A — Event-driven fan-out (common)
- Orchestrator publishes
UserDeletionRequested(subject_id, request_id, deleted_at, ...).
- Each service:
- deletes local data,
- publishes
UserDeletionCompleted(service, subject_id, request_id, completed_at, stats...).
Pros: simple, scalable.
Cons: verification/SLAs require careful tracking.
Pattern B — Orchestrator-driven task dispatch (tighter control)
Orchestrator creates explicit tasks: (service=X, subject_id, request_id) in a queue/table, retries until completion.
Pros: clearer progress tracking.
Cons: more central complexity.
Critical reliability detail: Outbox pattern
To avoid “DB committed but event not published”:
- Write deletion state + outbox event in the same transaction.
- A relay publishes outbox to the bus.
4) End-to-end flow (recommended “state machine”)
Phase 0: Intake
- Validate request, authentication, and policy (e.g., legal hold exceptions).
- Create a deletion case:
CREATE TABLE deletion_cases (
request_id UUID PRIMARY KEY,
subject_id UUID NOT NULL,
requested_by TEXT NOT NULL, -- actor id, not email
requested_at TIMESTAMPTZ NOT NULL,
status TEXT NOT NULL, -- "OPEN", "IN_PROGRESS", "COMPLETE", "FAILED"
policy_version TEXT NOT NULL,
notes_ref TEXT NULL -- reference to secure system, not raw text
);
Phase 1: Create tombstone (atomic gate)
Transaction:
- Insert tombstone (or confirm it already exists).
- Mark case
IN_PROGRESS.
- Write outbox event
UserDeletionRequested.
This ensures non-resurrection begins immediately.
Phase 2: Fan-out delete
Each service’s worker:
- checks tombstone (optional but recommended),
- deletes local data,
- writes a local “service deletion log” (minimal),
- emits
UserDeletionCompleted.
Deletion actions include:
- DB rows (hard delete)
- caches (invalidate)
- search index removal
- object storage delete (or key shredding)
- third-party processors (issue delete requests)
Phase 3: Orchestrator collects acknowledgments
A table to track per-service status:
CREATE TABLE deletion_service_status (
request_id UUID NOT NULL,
service_name TEXT NOT NULL,
status TEXT NOT NULL, -- "PENDING","DONE","FAILED"
updated_at TIMESTAMPTZ NOT NULL,
details_ref TEXT NULL, -- avoid PII; store links to internal logs
PRIMARY KEY (request_id, service_name)
);
When all required services are DONE, move to verification.
Phase 4: Verification & close
- Run verification jobs (see section 7).
- If pass → mark case
COMPLETE.
- If fail → reopen tasks, alert, or mark
FAILED with remediation.
5) Audit trail (privacy-safe)
What to log
request_id, subject_id (internal id), timestamps
- actor type (user/admin/system), authorization basis
- services completed + completion timestamps
- exceptions (legal hold, partial deletion policy)
What not to log
- raw emails, phone numbers, addresses
- deleted content
- full database queries with literals that include PII
Where to store audit
- Append-only store (e.g., WORM-capable log, immutable table, or dedicated audit system)
- Strict access controls, separate from product analytics
- Retention policy consistent with legal/compliance needs
6) Backfills (for legacy tables, new discoveries, warehouses)
Backfills are how you fix the inevitable: “we found a table we forgot” or “warehouse rebuild brought back data”.
Backfill strategy
- Source of truth = tombstones
Backfill job reads tombstoned subject_ids and scans target stores.
- Chunk + rate limit
Avoid melting production DBs; do off-peak where possible.
- Progress tracking
Use a backfill_runs table keyed by (store, shard, cursor).
Example: warehouse backfill
- Maintain a
deleted_subjects dimension derived from tombstones.
- ETL jobs join/filter to exclude deleted subjects.
- Periodic delete/rewrite partitions that still include tombstoned subjects (depends on your warehouse technology).
7) Verification jobs (prove deletion + prevent regression)
Verification should be continuous, not just at request time.
Types of verification
A. Online “spot checks” per case (closure gate)
For a given request_id/subject_id, each service runs a lightweight query:
SELECT COUNT(*) FROM ... WHERE subject_id = ?
- object storage: check prefix empty / metadata deleted
- search: confirm no docs for subject
Services report Verified=true/false to orchestrator.
B. Periodic global sweeps (regression detection)
Daily/weekly job:
- sample or full-scan deleted subjects
- confirm absence across key stores
- alert on any reappearance
C. Stream regression check
If you have event replay/ETL rebuilds, verify consumers enforce tombstones:
- metric: “events dropped due to tombstone”
- alert if it suddenly becomes 0 during replays or spikes unexpectedly
8) Handling hard cases (you should decide explicitly)
Backups
You often can’t delete individual rows from immutable backups. Common approaches:
- Crypto-shredding: encrypt per-subject or per-tenant keys; delete the key to make data irrecoverable.
- Restore-time filtering: if you restore, you must re-apply tombstones/backfills immediately before going live.
- Document this in policy and audit.
Aggregates and analytics
- If truly aggregated and non-identifying, may be retained.
- If user-level event logs exist, they should be deletable or irreversibly de-identified.
- Make this a formal “data classification” rule, not an ad-hoc decision.
Legal holds / fraud investigations
- Add a “hold” state: tombstone may still block access, but physical deletion can be delayed with a recorded basis.
- Don’t silently ignore deletion requests—record the exception path in audit.
Third parties
- Treat external processors as “services” in your deletion graph.
- Track request IDs and confirmations (or periodic polling).
- Have retry + escalation paths.
9) Operational controls (what makes it production-grade)
- Idempotency keys:
request_id must make every step safe to retry.
- Dead-letter queues + alerting for failed service deletions.
- Timeout SLAs: e.g., “all services within 7 days”, with escalation.
- Metrics:
- time-to-complete per service
- failure rates
- number of tombstoned events dropped
- verification pass/fail counts
- Access controls: only a small group can view deletion case details.
- Change management: any new table/store requires updating the deletion graph + adding verification coverage.
10) A concrete “minimum viable” implementation plan
- Standardize identifiers (
subject_id) across services.
- Build tombstone registry + enforce it in:
- auth/account flows
- event consumers
- ETL outputs
- Add orchestrator + service checklist (start with your top 5 systems).
- Implement per-service deleter workers and
UserDeletionCompleted acknowledgments.
- Add audit trail (append-only, no PII).
- Add case-level verification (closure gate).
- Add periodic sweeps + backfill tooling for new/legacy stores.
- Extend to:
- object stores/search/caches
- warehouses
- third parties
- backups via crypto-shredding / restore filtering
If you share your stack (Kafka vs SQS/PubSub, Postgres vs DynamoDB, warehouse/search providers) and your service count, I can sketch a concrete event schema, tables, and worker logic tailored to it (including retry/backoff and exactly-once-ish guarantees with outbox).