question 496 Production Readiness Capstone · medium
One batch missing after every restart
Operations noticed that whenever the nightly job is restarted after a crash, exactly one batch of trips never reaches the report, and the written count in the morning summary is one too high. Find and fix the bugs in resume_night.
Function
resume_night(batches, sink, state); state is {"done": n} (batches already written)Behaviourwrite batches
state["done"] onward with sink.write(batch), setting state["done"] to number + 1 after each writeReturnsthe number of batches written by this call