"latest" integer in AppState isn’t persistent between runs #16

Closed
opened 2026-02-21 19:57:34 +01:00 by marfavi · 2 comments
Owner

The simulator API keeps a latest integer in AppState (an AtomicI64) which is updated from the latest query‑parameter on each request and returned by GET /latest.

Currently that value is only stored in memory and initialised to -1 when the server starts:

let app_state = Arc::new(AppState {
    …,
    latest: AtomicI64::new(-1),
});

No code ever writes it to the database or disk, so when you stop/restart the container the value is reset. This makes it impossible for the server to remember its last‑seen value across deployments.

Suggested fix: Persist the value somewhere (such as a new row in SQLite or a small file in the mounted volume) and load/update it through the existing service layer, so container rebuilds and restarts don’t lose it.

The simulator API keeps a latest integer in AppState (an AtomicI64) which is updated from the latest query‑parameter on each request and returned by GET /latest. Currently that value is only stored in memory and initialised to -1 when the server starts: ```rust let app_state = Arc::new(AppState { …, latest: AtomicI64::new(-1), }); ``` No code ever writes it to the database or disk, so when you stop/restart the container the value is reset. This makes it impossible for the server to remember its last‑seen value across deployments. Suggested fix: Persist the value somewhere (such as a new row in SQLite or a small file in the mounted volume) and load/update it through the existing service layer, so container rebuilds and restarts don’t lose it.
Owner

Should be fixed, see 10da5395a3

Should be fixed, see 10da5395a3
Author
Owner

Commit was reverted

Commit was reverted
marfavi reopened this issue 2026-02-27 13:50:48 +01:00
marfavi added this to the MiniTwit project 2026-02-27 13:53:28 +01:00
marfavi self-assigned this 2026-02-27 13:54:52 +01:00
Commenting is not possible because the repository is archived.
No milestone
No project
2 participants
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
DevOpps/minitwit#16
No description provided.