Scrivio Interview library
LeadershipPrincipal7 min read · updated 13 November 2026

Legal requires that a customer's personal data in the event platform be deletable within 30 days of a request.

Today some delete-policy topics keep data for a year, some compacted topics hold customer state, and tiered storage keeps old segments in object storage. How do you set the long-term retention and deletion policy?

I would treat this as a data governance policy, not a Kafka setting. Every topic gets a classification for personal data, an owner, a purpose and a maximum retention; delete-policy topics with personal data keep it no longer than the 30-day deadline unless there is a stated legal basis. Compacted state topics delete with a tombstone on a key that identifies the person, which must reach every consumer's store; long-lived logs keep personal fields out of events (references instead of values) or encrypt them with a per-person key that we delete (crypto-shredding). Deletion must cover every copy, tiered storage, mirrors, sinks and backups, and we enforce the policy with topic policies and audits, offering replay from source systems to replace long retention.

Why this question is asked

Event platforms are built to keep data and copy it everywhere, which is exactly what makes them hard to reconcile with a right to erasure. A one-year topic, a compacted state store, tiered storage in object storage, mirrors to another region and sinks into a data lake can each hold the same customer's data, and a deletion request must reach all of them within 30 days. Interviewers ask this leadership question to see whether we can set a policy that is legally sound, technically workable and enforceable across many teams. In this answer, we will recap how each kind of topic retains data, classify the topics, handle compacted topics, handle long-lived logs, cover every copy, and make the policy enforceable while acknowledging its cost.

1A Quick Recap of How Each Topic Type Keeps Data

A delete-policy topic keeps records until their segment is older than retention.ms; nothing can remove a single record before that. So a topic with one-year retention holds every customer's data for a year, whatever anyone requests. A compacted topic keeps the latest record per key, and the only way to remove a key is a tombstone, a record with a null value, which the cleaner eventually applies.

Tiered storage moves older closed segments of a topic to object storage, such as S3, while the broker keeps recent ones locally. Retention applies to the whole log, local and remote, so the remote copy is deleted on the same schedule, but it is still a copy that must be counted. And many topics are mirrored to other clusters or sunk into lakes, warehouses and search indexes, each with its own retention.

2Classifying Topics and Setting Retention by Class

The policy starts with knowing what we have. Every topic must be classified by whether it contains personal data, and must have an owner and a stated purpose. Topics without personal data keep their current retention. For topics with personal data, retention is set by purpose, and on delete-policy topics it must be within the 30-day deadline, so that data subject to a request is gone in time, unless there is a documented legal basis to keep it longer, such as financial records that law requires us to retain for years.

This immediately resolves the one-year topics: either they stop carrying personal data, or their retention comes down, or their legal basis is written down and approved. The classification is stored as topic metadata so it can be checked automatically.

Deletion approach by topic type
Topic typeHow a person's data is removedMain risk
Delete policy, short retentionexpires within 30 daysretention set too long
Delete policy, long retentionkeep personal data out, or crypto-shredfields leaking into events
Compacted statetombstone on the person's keykey not tied to the person
Tiered storagesame retention as local segmentsremote copy forgotten in audits
Mirrors, sinks, backupsown deletion process per systemdeletion stops at Kafka
Each type needs its own mechanism; one setting cannot cover them all.

3Compacted State Topics

For a compacted topic of customer state, deletion is natural: publish a tombstone for the customer's key, and compaction removes all older values. This works only if two conditions hold. The key must identify the person, so we can find every record about them; if customer data is spread across topics keyed by order id or session id, a tombstone on the customer id removes nothing there. And the tombstone must reach every consumer's store before it expires, which means delete.retention.ms must exceed the slowest reader's full bootstrap, and every service that materialises the topic must apply deletes.

We also check the timing against the deadline: compaction must actually run within the 30 days. Setting max.compaction.lag.ms on these topics forces the cleaner to compact superseded data within a bound, so an old value cannot linger in an uncleaned segment past the deadline.

4Long-Lived Logs: Keep Values Out or Shred the Key

Some topics have good reasons for long retention, such as event sourcing or replay for analytics. For them, two designs keep personal data deletable. The first is to keep personal fields out of events: an event says customer 4711 changed their address, and the address itself lives in a database that supports deletion. The event remains, but it no longer identifies a person once the customer record is deleted, subject to legal advice on what counts as anonymous.

The second is crypto-shredding. Personal fields in each event are encrypted with a key specific to that person, stored in a key management service. To erase the person, we delete their key. The events stay in the log, in tiered storage and in every copy, but the personal fields are unreadable everywhere at once. It requires key management and changes to producers and consumers, but it is the only approach that deletes data from copies we cannot rewrite.

Java
// producer: encrypt personal fields with the customer's own key
SecretKey k = keys.forCustomer("4711"); // created on first use
String email = crypto.encrypt(k, "ana@example.com");
send(new CustomerEvent("4711", "ADDRESS_CHANGED", email));
// erasure request
keys.delete("4711"); // every stored copy of the email is now unreadable
crypto.decrypt(keys.forCustomer("4711"), email); // fails: key no longer exists

5Covering Every Copy and Making It Enforceable

Deletion is only as good as the last copy. The policy must list every place data flows: tiered storage, which follows topic retention but should be included in audits; mirrored clusters, which need the same retention and must replicate tombstones; sinks such as a data lake or search index, which need their own deletion jobs driven by the same requests; and backups, which must expire within the deadline or be excluded from holding personal data. A deletion request is tracked until every system confirms it.

Enforcement uses the platform's controls. Topic creation and config changes go through a policy, with create.topic.policy.class.name and alter.config.policy.class.name or a topics-as-code pipeline, that rejects a personal-data topic with retention above its class. Regular audits compare actual configs, schemas and sinks against the classification, and sample events for personal fields that should not be there.

Finally, we accept and explain the cost. Shorter retention means teams can no longer replay a year of events from Kafka. Instead we offer replay from the source systems, or from anonymised archives, which is slower but compliant. Presenting that trade-off openly, with the legal risk on the other side, is what makes the policy stick.

6Follow-up questions

Can we just delete records from a delete-policy topic on request?

No. Kafka has no operation to remove an individual record from a delete-policy topic; data goes only when its segment expires. The admin API can delete all records before an offset in a partition, which removes everyone's older data, not one person's. That is why retention within the deadline, keeping personal data out, or crypto-shredding are the real tools.

Does crypto-shredding satisfy legal deletion?

It is widely used and often accepted, because the data becomes unreadable everywhere, but whether encrypted data with a destroyed key counts as erased is a legal judgement. The policy should be reviewed with legal counsel, and key deletion must be reliable and audited.

Who owns a deletion request end to end?

A central privacy workflow should own it: it receives the request, fans it out to every system that holds the person's data, and tracks confirmations until the deadline. Kafka is one participant; the platform team provides tombstone publishing, key deletion and audit evidence.

7Conclusion

In this answer, we set a deletion policy around classification: every topic has an owner, a purpose and a maximum retention, and personal data on delete-policy topics stays within the 30-day deadline unless a legal basis is documented. Compacted state topics delete with tombstones on a key that identifies the person, with timing settings that make them reach every store; long-lived logs keep personal fields out or use crypto-shredding. Every copy, tiered storage, mirrors, sinks and backups, is covered, the policy is enforced with topic policies and audits, and replay moves to source systems as the accepted cost.

What to say in the interviewAbout 90 seconds aloud

Open with

I would make this a governance policy first and a set of configs second. Every topic gets a classification for whether it carries personal data, plus an owner, a purpose and a maximum retention.

Then, if they want more

For delete-policy topics with personal data, retention must be within the 30-day deadline, because Kafka cannot remove a single record; the year-long topics either stop carrying personal data, shorten retention, or document a legal basis.

For compacted customer-state topics, deletion is a tombstone on the customer's key, which only works if the key really identifies the person and every consuming service applies the tombstone to its store, so delete.retention.ms must exceed the slowest bootstrap, and max.compaction.lag.ms makes sure compaction happens in time.

For logs we want to keep long, I would keep personal fields out of events and use references, or encrypt personal fields with a per-person key and delete that key on request, which is crypto-shredding and covers copies we cannot rewrite.

Then I would cover every copy: tiered storage, mirrored clusters, sinks like the data lake and search, and backups, with a deletion workflow that tracks each system to confirmation. I would enforce it with create and alter topic policies and regular audits, and be honest about the cost: less replay from Kafka, so we offer replay from source systems instead.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Today some delete-policy topics keep data for a year, some compacted topics hold...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-internals/9960aac988/