Skip to content

fix(server): the store lock is held across the blocking LLM call in capture extraction #1663

Closed

Description

@ajianaz

What

capture_worker::run_cycle (crates/uteke-server/src/capture_worker.rs:40) locks the shared Mutex<Uteke> and calls run_capture_extraction inside the guard's scope. That function calls facts.extract(), a blocking HTTP request to the LLM provider with a 120 s timeout (extraction.rs REQUEST_TIMEOUT_SECS). While it runs, every recall, remember and viewer request that needs the mutex waits.

Why

The module doc says the lock is taken per session so a run does not hold requests back for its whole length. That holds for the run, not for each session: one slow provider call still blocks the server for up to two minutes, and a hung provider does so on every scheduled run. Found by a Cora scan run as agent on the files added since v0.22.1 (2026-11-04). Line numbers are for develop @ 7e53cec.

Proposal

Split extraction into three steps: claim the batch and read its turns under the lock, release the lock, call the extractor, then re-take the lock to store the facts and mark the batch done. The batch lease already makes this safe against a crash in between.

Testing

  • A fake FactSource that sleeps: a concurrent recall on the same Mutex completes while the extraction is still running.
  • A crash between claim and store (extractor error, panic) leaves the batch recoverable, as today.

Activity

  1. added
    bug
    scope:core
    priority:high
    cora-scan
    scope:server
    on Nov 4, 2026
  2. ajianaz commented on Nov 4, 2026

    @ajianaz
    CollaboratorAuthor

    Fixed by #1674 (merged): the lock is held only to claim a batch and to store its facts, not across the extractor call.

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

    bugcora-scanpriority:highscope:corescope:server

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions