Persist state after initial scan and meaningful progress #13

Closed
opened 2026-05-11 18:52:28 +02:00 by heiko · 4 comments
Owner

Problem

State is updated in memory after initial scan and during processing, but run saves it only when a mailbox goroutine exits.

References: cmd/xr-invoiced/main.go:140 and cmd/xr-invoiced/main.go:242.

A crash or hard kill after a long initial scan loses the updated position and causes a full rescan on the next start.

Expected

State should be persisted after expensive initial scans and after meaningful progress, not only at shutdown.

Suggested fix

Save after initial scan completes, and consider periodic or per-batch saves while processing IDLE/reconnect results.

## Problem State is updated in memory after initial scan and during processing, but `run` saves it only when a mailbox goroutine exits. References: `cmd/xr-invoiced/main.go:140` and `cmd/xr-invoiced/main.go:242`. A crash or hard kill after a long initial scan loses the updated position and causes a full rescan on the next start. ## Expected State should be persisted after expensive initial scans and after meaningful progress, not only at shutdown. ## Suggested fix Save after initial scan completes, and consider periodic or per-batch saves while processing IDLE/reconnect results.
Author
Owner

Branch renamed per convention:

Old: regression/issue-13-state-progress-save
New: fix/13-state-progress-save

The old remote branch has been deleted.

Branch renamed per convention: Old: regression/issue-13-state-progress-save New: fix/13-state-progress-save The old remote branch has been deleted.
Author
Owner

Fix branch pushed: fix/13-state-progress-save-claude

Adds saveStates func() parameter to runMailbox and calls it after updating state in the UIDValidity-changed branch, ensuring progress is persisted before entering IDLE. Regression test passes.

Fix branch pushed: [fix/13-state-progress-save-claude](https://forgejo.schlittermann.de/IUS/xr-invoiced/src/branch/fix/13-state-progress-save-claude) Adds saveStates func() parameter to runMailbox and calls it after updating state in the UIDValidity-changed branch, ensuring progress is persisted before entering IDLE. Regression test passes.
Author
Owner

Implementation branch: fix/13-state-progress-save-codex

Implementation branch: [fix/13-state-progress-save-codex](https://forgejo.schlittermann.de/IUS/xr-invoiced/src/branch/fix/13-state-progress-save-codex)
Author
Owner

Fixed in b4b048c, merged by 8b59369. State is saved after initial scan and after progress in startup/idle paths; regression coverage is present in state_progress_regression_test.go.

Fixed in b4b048c, merged by 8b59369. State is saved after initial scan and after progress in startup/idle paths; regression coverage is present in state_progress_regression_test.go.
heiko closed this issue 2026-05-13 14:11:46 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
IUS/xr-invoiced#13
No description provided.