Skip to content

appendLog lost-update race: 20 concurrent appends -> 2 survived #23

Closed

Description

@abogartz

Found by the 2026-10-21 security review (SECURITY-REVIEW-2026-10-21.md, finding F4). Reproduced on main 286d2ba.

appendLog in src/logfmt.ts is read-modify-write with an await between read and write. Probe: 20 concurrent appendLog calls to one file → 2 survived.

Impact: lost rows under any concurrency — interleaved async hooks in the service, and service vs. viewer (separate processes). Same failure family as the 2026-10-20 undo-clobber incident: conflict-aware restore fixed the restore side; the append side still races. Every memory and evidence append goes through this function.

Fix direction (P0): single write via Bun's append mode (O_APPEND, atomic for small POSIX writes) instead of existing + next; keep read-modify-write only for in-place edits. Test: 50 concurrent appends must all be present. (Residual: in-place supersede rewrites racing appends needs a lockfile — tracked separately.)

Activity

  1. added
    bug
    on Oct 21, 2026
  2. added a commit that references this issue on Oct 21, 2026
    2361256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions