HomeInterview QuestionsIn a pipeline where the same source file can arriv…

In a pipeline where the same source file can arrive twice downstream, how would you design the pipeline to ensure exactly one clean result is produced? What strategies would you use to handle replay and maintain idempotency?

🟡 Medium System Design Mid level
1Times asked
Jul 2026Last seen
Jul 2026First seen

💡 Model Answer

To guarantee a single clean result, I design the pipeline to be idempotent by using a deterministic key for each record, such as a hash of the file name and a unique record identifier. I store processed keys in a transactional table (e.g., DynamoDB or a Delta Lake table) with a unique constraint. When a file arrives, the pipeline first checks the key table; if the key exists, the file is skipped. For replay handling, I use a message queue (Kafka or SQS) with exactly-once semantics and enable idempotent writes to the destination (e.g., S3 with versioning or a Delta Lake table). I also implement a watermarking strategy to discard late-arriving duplicates after a certain time window. The pipeline stages include: ingestion → de-duplication (key lookup) → transformation → write with idempotent commit. This architecture ensures that even if the same source file is replayed, only one clean result is produced, and the system can recover from failures without data corruption.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500