Representative interview topic

Data Engineering Interview: How Would You Design an Auditable Distributed Data-Deletion Pipeline?

DataHard
Offer.cc Editorial TeamPublished Updated

Question

A user requests account deletion, but data exists in databases, object storage, search indexes, analytics warehouses, and backups. How would you design the pipeline and prove complete coverage without violating retention duties?

Prompt and context

This question tests whether a data engineer can turn one deletion request into a cross-system, retryable, auditable lifecycle. Deletion is more than a primary-database DELETE; it includes derived tables, caches, indexes, event logs, backups, and processors. Cover discovery, identity mapping, legal holds, idempotency, recovery, and proof of completion.

What the interviewer tests

Strong answers define scope and exceptions, then build a data catalog with owners. A workflow sends delete or anonymize commands along dependencies and waits for receipts. States distinguish requested, running, verified, and blocked, with an immutable audit trail. If physical backups cannot be edited immediately, explain encryption erasure, expiry, restore isolation, and reapplication.

Questions to clarify

  • What identifies the person, and how are email, device, order, and anonymous identifiers linked?
  • Which records must disappear, and which invoices, fraud evidence, or legal holds must remain temporarily?
  • Are search indexes, caches, aggregates, event logs, object storage, backups, and SaaS processors included?
  • Is the target physical deletion, irreversible anonymization, or stopping use within a deadline?
  • What defines completion, timeout, human review, and the user receipt?

30-second answer framework

“I would catalog systems, fields, owners, retention rules, and deletion capabilities. Each request creates an immutable deletion case and idempotent tasks. The orchestrator sends delete, anonymize, or key-erasure commands along dependencies; each consumer returns scope, version, and a verification summary. Failures retry or escalate. Legal-hold data is access-frozen with a recorded exception and deleted when the hold expires. Completion requires catalog coverage, receipts, sampled reads, and an audit trail; the user receives honest status without internal topology.”

Step-by-step deep answer

Step 1: Build a data and identity map

Catalog tables, buckets, indexes, field classes, owners, downstream dependencies, backup cycles, and processors. Map the stable user id to orders, devices, emails, and anonymous tokens. Without reliable identity joins, a complete-deletion claim is not credible.

Step 2: Define deletion policy

Classify records as direct deletion, anonymization, aggregate retention, or legal hold. Financial records or fraud evidence may need retention, but minimize fields, restrict access, and record the legal basis. Version the policy so old requests remain explainable.

Step 3: Create an idempotent case

Create case_id, subject id, policy version, deadline, and source. Every target receives the case id and returns the same result on repetition. Use states such as requested, running, verified, blocked, failed, and expired.

Step 4: Propagate along dependencies

Delete the source record or emit a tombstone, then trigger CDC consumers for indexes, caches, and derived warehouses. Batch systems need a suppression table so later jobs do not recreate the subject. Third parties confirm through an API receipt or contractual process.

Step 5: Handle backups and key erasure

Backups usually expire on a schedule. If individual edits are impossible, isolate restore access, keep a deletion manifest, and reapply deletion during restore. Per-subject encryption keys can make sensitive ciphertext unrecoverable after key destruction, but this is not a universal legal shortcut.

Step 6: Verify beyond success codes

Consumers return counts, versions, partitions, and checksums. The orchestrator samples reads in the primary store, index, warehouse, and object store, and checks cache invalidation and CDC watermarks. Failed verification creates compensating work instead of closing the case.

Step 7: Isolate retention exceptions

Store legal-hold records separately with minimal fields and no product queries. The case report contains scope, legal basis, owner, and review date. Releasing a hold automatically creates a new deletion task; an exception cannot become a permanent blacklist.

Step 8: Audit, alert, and respond

Audit logs contain irreversible subject digests, actor, time, policy version, and result, not sensitive payloads. Monitor case age, failure rate, catalog coverage, third-party receipts, and restore drills. Users see completed, processing, or legally held status with a clear deadline.

Deletion workflow pseudocode

text
case = create_case(subject, policy_version)
for target in catalog.targets(subject, policy_version):
    enqueue_idempotent(case.id, target, action_for(target))
verify_samples(case)
close(case, "verified" if all_verified(case) else "blocked")

Trade-offs and boundaries

ScenarioStrategyCost
Primary and indexTombstone plus async deletionPropagation delay
Analytics aggregateRemove identifying detail and recomputeCompute cost
Long-lived backupExpiry or replay deletion during restoreNot immediate row erasure
Legal holdMinimize fields and freeze accessReview and governance

Proof should cover where the system looked, which targets acknowledged, and which exceptions remain. It should not promise unverifiable physical disappearance. Google Cloud describes deletion as a staged pipeline in which data remains protected until the stages complete.

Rollout plan and evidence

Choose one user dataset and connect a catalog, identity map, primary store, index, and warehouse. Inject duplicate messages, offline consumers, backup restore, and policy changes. The European Commission documents legal exceptions to erasure; Google Cloud documents staged deletion; TechInterview’s public design question calls out microservices, object storage, analytics, backups, and audit trails.

Pilot exit criteria

Catalog coverage is measurable; every target has an owner and capability; repeated requests are idempotent; failures retry or escalate; sampled verification finds residuals; holds have a basis and expiry; and the user receipt matches internal state.

How to prove the gain is real

Compare unregistered datasets, completion time, residual rate found by verification, retry rate, and human intervention before and after. Drill offline consumers, backup restore, and third-party timeout rather than measuring only the happy path.

Common mistakes and follow-ups

Deleting only the primary row

Indexes, caches, warehouses, and object stores may still return data. Catalog coverage and downstream receipts must be completion criteria.

One global DELETE event for every system

Consumers need different actions and versions. Without idempotency, receipts, and watermarks, events can be lost or repeated. Use a case-id workflow.

Claiming backups are immediately erased

Many backups expire on a schedule. Explain access isolation, deletion manifests, restore replay, and final overwrite time.

How do legal holds avoid blocking all deletion?

Minimize the held scope, freeze access, record basis, owner, and review date, and continue deleting everything outside the hold.

How do you stop data from being recreated?

Emit a source tombstone or suppression record; CDC and batch jobs check deletion state before creating derivatives, and replay reapplies the policy.

What if the user demands immediate completion?

Distinguish verified targets from time-bounded backup or third-party steps, return processing status and a deadline, and never invent a completed physical erase.

Public sources

Related questions