Skip to main content
Version: Next

Replay and backfill

Replay re-processes input that has already been consumed; backfill loads a historical range into a new or rebuilt pipeline. Both are manual operations you drive by moving a source's start position; they are distinct from the automatic WAL replay that happens after a crash, which the engine performs by itself from the durable log.

Prerequisites​

  • A replayable source: Kafka (group offsets), MQTT QoS ≥ 1, NATS JetStream, Pulsar — or a non-replayable source whose messages the WAL still retains within its replay window.
  • A downstream that tolerates duplicates, or an idempotent sink. Replay is at-least-once by definition; plan idempotency first (UPSERT keys, point ids, dedup-on-write), not after.
  • Know the range: offsets/time range for Kafka-style sources, or the WAL retention bounds for a WAL replay.

Replay by Kafka offset​

Kafka input start positions come from the consumer group's committed offsets; a reset applies only when there is none in range. To replay a range:

  1. Stop the stream that owns the consumer group.

  2. Reset the group's offsets to the replay start (offset or timestamp) with your Kafka tooling — ArkFlow does not manage group offsets:

    kafka-consumer-groups --bootstrap-server localhost:9092 \
    --group my-group --reset-offsets --to-datetime 2026-12-01T00:00:00.000 \
    --topic orders --execute
  3. Restart the stream (same consumer group). It resumes from the reset position.

  4. Verify the downstream: row counts per key, absence of gaps at the join boundary, and the absence of a growing error_output rate.

For a new deployment replaying retained history, set start_from_latest: false and either a fresh consumer group (starts at the earliest available offset) or a reset group — see the Kafka input reset semantics: with a single consumer subscription a committed in-range offset wins, so a fresh group is the deterministic way to start at the beginning.

Replay from the WAL (non-replayable sources)​

A WAL keeps messages within its retention; replaying rewinds to a stored position:

  1. Stop the stream.
  2. Lower the WAL cursor (or restore a snapshot of the WAL directory taken at the desired position) — the cursor is the replay start.
  3. Restart; the stream replays from the cursor through the present.

The exact rewinding procedure and the retention caps (max_segments / max_age / max_bytes) that bound how far back you can go are in WAL durability.

Savepoint-based rerun (Jobs)​

For stateful Jobs, a savepoint captures state and positions without the retention pressure of checkpoints. To re-run a window of history with correct state:

  1. Take a savepoint (POST /api/v1/jobs/{id}/savepoints or the console).
  2. Stop the job, fix or reset what you need.
  3. Start the job pinned to that savepoint; it resumes state and positions from the artifact. Rescaling across the rerun requires rescale: true (see rescaling on recovery).

Pause/resume uses the same artifact path — see paused jobs.

Downstream idempotency​

SinkIdempotency mechanism
SQL (UPSERT mode)upsert_keys conflict clause
Qdrant / Milvus / pgvectorPoint/row id overwrite (see batch atomicity)
KafkaDownstream consumers dedup by key; or enable the L3 pairing for Kafka→Kafka
HTTPIdempotency key on the receiver side
InfluxDBTimestamp + tag natural idempotency

If none of these hold, add a dedup stage downstream (e.g. the dedup SQL pattern on the consumer) before the replay window, or accept the duplicates and document them.

Cost and verification​

  • Cost. A replay re-pays processing and sink write cost for the whole range; object-store WAL replays also pay GET traffic. Backfill off-peak and rate-limit the source if the sink is shared.
  • Verification. Compare pre/post row counts for the replayed range, spot check a few keys end-to-end, and watch arkflow_job_chain_dlq_routed_total and error_output for surprises.
  • Bound the blast radius: replay one stream/group at a time, and prefer a separate consumer group + staging sink for full re-processing.

Rollback​

There is no undo for an over-scoped replay: the duplicates are downstream. Mitigate by replaying into an idempotent sink (overwrites converge), or by routing the replay to a staging sink and switching over after verification.