The problem

A reporting platform copied records from operational databases into analytical storage. I worked on queue processing and the rules for copying and deleting those records.

Queue processing

The worker read a list of identifiers from Redis and deleted the list in a separate operation. If another process added an identifier between the read and delete, the worker could discard it without processing it. I replaced that sequence with atomic Redis pops.

I split processing into batches that fit the downstream operation and added exception handling to return unfinished work to the queue.

A process crash between popping and processing can lose work. To cover that failure, a worker would need a durable acknowledgement or recovery mechanism beyond exception handling.

Backfill and cleanup

For historical data, I bounded a backfill query by the maximum eligible identifier so it would stop at the date cutoff instead of scanning newer records.

I limited source cleanup using the last completed copy cursor. Cleanup could delete a record after both its retention period had elapsed and the copy process had reached it.