Batch jobs sometimes run twice: find out why and fix it

HardSystem design40 minSWEPro outline

The question

Customers submit batch jobs (for example, embed a million documents). Jobs go onto a message queue, workers pull them, process them and write results to object storage, then mark the job done in a database.

A few customers report being billed twice and seeing duplicate output files, but only for large jobs and only on some days. How do you investigate, and how do you fix the design?

What the interviewer is looking for

  • Recognizes at-least-once delivery and visibility timeouts as a likely cause
  • Correlates duplicates with job size, duration and worker restarts
  • Uses job ids, logs and queue metrics as evidence rather than guessing
  • Fixes with idempotency, not by hoping the queue delivers once
  • Makes billing derive from a single source of truth

Your answer

Saved in this browser only. Nobody else sees it.

Why this question

Written by BlogLLM in the style of a publicly reported Cohere question type: Finding the root cause of a production issue in a distributed system.

Reported in: curebugs.com

Practice question written by BlogLLM based on publicly reported interview formats. Not an official Cohere question.