Checkpointing a Batched Database Import

A batched import can record its last fully committed input position so a resumed run does not skip or duplicate work.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a small interrupted batch
  2. Keep step and data consistent
  3. Record progress with the data it describes
  4. Tie checkpoint to a stable source

Trace a small interrupted batch

Two batches of ten have committed. The third fails before completing. The checkpoint should still refer to the end of the second batch. Recovery checkpoints establish that rule.

Keep step and data consistent

Store both together when possible. If they live in separate systems, make reprocessing safe under a documented key. Repeat request identity supplies one concrete pattern.[1]

Record progress with the data it describes

An importer reads immutable numbered chunks. If chunk three writes records and the process stops before saving its checkpoint, restart can repeat the chunk. Committing data and checkpoint together can make advancement correspond to a durable batch. See fixed-size batches.

Last confirmed checkpoint: 2
Begin chunk 3 → write data and checkpoint=3
Commit together
Resume from chunk 4 after committed success

Tie checkpoint to a stable source

Reusing a checkpoint on a changed file can skip or duplicate records. Include source identity or snapshot and make retries safe. Test interruption immediately before and after the batch commit.

References

  1. PostgreSQL Global Development Group, Concurrency Control ↩