Backend follow-ups: release idle users, prune idempotency, access log #109

Closed
kayg wants to merge 0 commits from issue/17-backend-followups into dev
Owner

Part of #17 (not closing it: OpenAPI and the dev shell are left for a later PR).

  • Idle users are released. The engine drops a user's runtime (writer thread and memory) after 10 minutes of quiet. It never drops one while an action runs, a live view is open, or anything else holds the store. Sweeps piggyback on incoming calls, so no timer thread. Reopening is the existing fast open.
  • Idempotency records are pruned after 7 days: at store open and hourly, on the writer thread. New additive migration adds an index on at_ms.
  • Access log: one access line per request: method, route pattern, status, ms. No query, headers, cookies, bodies, or raw paths. /healthz logs at debug.
  • CI pin: .forgejo/workflows/ci.yml has no uses: at all (caches are runner volumes), so there is nothing to pin. Moot.

Tests: idle user returns with nothing lost (journal, replay of old key, continued seqs, writer thread really exits); live view / running action keeps a user open; a hammer test (4 users x 4 writers x 40 actions while a sweeper drops everyone at zero idle time) loses no write; prune at open and after commit; access log has no secrets.

Memory numbers are on the issue.

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

Part of #17 (not closing it: OpenAPI and the dev shell are left for a later PR). - **Idle users are released.** The engine drops a user's runtime (writer thread and memory) after 10 minutes of quiet. It never drops one while an action runs, a live view is open, or anything else holds the store. Sweeps piggyback on incoming calls, so no timer thread. Reopening is the existing fast open. - **Idempotency records are pruned** after 7 days: at store open and hourly, on the writer thread. New additive migration adds an index on `at_ms`. - **Access log**: one `access` line per request: method, route pattern, status, ms. No query, headers, cookies, bodies, or raw paths. `/healthz` logs at debug. - **CI pin**: `.forgejo/workflows/ci.yml` has no `uses:` at all (caches are runner volumes), so there is nothing to pin. Moot. Tests: idle user returns with nothing lost (journal, replay of old key, continued seqs, writer thread really exits); live view / running action keeps a user open; a hammer test (4 users x 4 writers x 40 actions while a sweeper drops everyone at zero idle time) loses no write; prune at open and after commit; access log has no secrets. Memory numbers are on the issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Backend follow-ups: release idle users, prune idempotency, access log
Some checks failed
CI / rust (pull_request) Successful in 1m35s
CI / web (pull_request) Failing after 1m29s
e72a1a2d1e
- Engine drops a user's runtime (writer thread, memory) after a quiet
  spell. Never while an action runs, a live view is open, or anything
  else holds the store. Nothing is lost: commits are on disk first.
- Idempotency records older than 7 days are swept at open and hourly.
- One compact access log line per request: method, route pattern,
  status, ms. No query, headers, cookies or bodies.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Author
Owner

Review: I read the engine and store diff.

  • Eviction race: callers clone the cell under the map lock, so sweep can't drop a runtime that get is about to use. is_unused covers live views and plugins holding the store.
  • No timer: sweeps run on the next call, so an idle server stays at zero CPU.

Local run: I merged current dev into this branch. engine, store, server and calternal all pass: 0 failures across 20 test binaries.

CI: the red runs are the 500 ms startup gate under a load average of about 100, plus web toast specs this PR doesn't touch.

Merging.

Follow-up for #44: about 100 MiB stays resident after release (glibc arenas). Try a different allocator, or malloc_trim after a sweep.

Review: I read the engine and store diff. - **Eviction race:** callers clone the cell under the map lock, so `sweep` can't drop a runtime that `get` is about to use. `is_unused` covers live views and plugins holding the store. - **No timer:** sweeps run on the next call, so an idle server stays at zero CPU. **Local run:** I merged current dev into this branch. engine, store, server and calternal all pass: 0 failures across 20 test binaries. **CI:** the red runs are the 500 ms startup gate under a load average of about 100, plus web toast specs this PR doesn't touch. Merging. **Follow-up for #44:** about 100 MiB stays resident after release (glibc arenas). Try a different allocator, or `malloc_trim` after a sweep.
kayg closed this pull request 2026-10-14 03:49:56 +00:00
Some checks failed
CI / rust (pull_request) Successful in 1m35s
CI / web (pull_request) Failing after 1m29s

Pull request closed

Sign in to join this conversation.
No reviewers
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
kayg/calternal!109
No description provided.