Wikis & learning

Batch a large Laravel reporting job

A reporting worker needs a stable way to resume after an interruption. Paging by numeric offset while rows are changing can skip or repeat work.

Question

Batch a large Laravel reporting job

Editorial answer

A reporting worker needs a stable way to resume after an interruption. Paging by numeric offset while rows are changing can skip or repeat work.

Use a monotonically ordered indexed ID for the cursor and choose a fixed upper bound when the run begins. Persist the last successful cursor together with the batch result in a transaction. Use a unique output key so retrying a batch gives the same result.

Verify the result

Stop the process after one committed batch and restart it. Compare the number of output records and the stored cursor with an uninterrupted run.

Discussion

Sign in to participate.