Skip to content

investigate: backfill.rs uncommitted_events tracking may have a real checkpoint bug #1832

Description

@Ndifreke000

cargo build warns on backend/src/jobs/backfill.rs:

warning: value assigned to `uncommitted_events` is never read
   --> src/jobs/backfill.rs:304:17
304 |                 uncommitted_events += events.len() as u64;
...
314 |                     uncommitted_events = 0;

and separately:

warning: unused variable: `last_ledger`
   --> src/jobs/backfill.rs:349:17
349 | ...   let last_ledger = current - 1; // It was updated before the break, wait, `current` is the next ledger to fetch, but the last ...

The inline comment on the last_ledger line ("wait, current is the next ledger to fetch,
but the last...") reads like an unfinished thought left mid-debugging, and the compiler
confirms uncommitted_events is incremented and then immediately overwritten with 0 before
ever being read — meaning whatever checkpoint/batch-commit logic this counter was meant to
drive is not actually running. For a ledger backfill job, a checkpoint counter that's
silently dead code could mean partial batches aren't being flushed/committed at the intended
cadence, which matters for both correctness (data loss on crash mid-backfill) and performance
(committing too rarely or too often).

Acceptance criteria:

  • Read the surrounding function in full and determine what uncommitted_events was
    supposed to gate (a periodic db.commit()/checkpoint write, a progress log line, a
    batch-size cap?)
  • Determine whether the current behavior (checkpoint effectively unconditional, or never
    firing) is actually a problem in practice, or if a different mechanism already covers it
  • Either wire the counter into real logic and add a test for the batching behavior, or
    remove the dead variable and clean up the stale comment if it turns out to be genuinely
    unnecessary
  • Resolve the last_ledger unused-variable warning the same way (understand its intent,
    not just underscore-prefix it)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions