Skip to content

fix(server): do not hold the store lock across the capture extractor call - #1674

Merged
ajianaz merged 1 commit into
developfrom
fix/capture-no-lock-across-llm
Nov 4, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/capture-no-lock-across-llm

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

What

  • Capture extraction is split into three steps in uteke-core (capture.rs): claim_capture_batch (claim and read the turns), extract_batch (every chunk, no store access) and finish_capture_batch (withdraw leftovers, store the facts, mark done or release). capture_housekeeping and capture_pending_sessions are the run's start. run_capture_extraction is now these steps in order, so uteke extract-queue run is unchanged in behaviour.
  • uteke-serve's run_cycle takes the Mutex<Uteke> only for the claim and for the finish, and releases it for the extractor call.
  • Because the session list is read once per cycle, housekeeping runs once per cycle, each session is tried once per cycle (before, a session the provider refused as too large would have been claimed again at once, burning its attempts in one cycle), and run_cycle checks shutdown between sessions.
  • Docs and CHANGELOG updated. The lease, attempts and capture:<session>:<batch> source semantics are unchanged, and the capture routes are LAB, so no contract change.

Why

run_cycle held the lock while facts.extract() made a blocking HTTP request of up to 120 s per chunk, so one slow provider call stalled every recall, remember and viewer request, and a hung provider did so on every scheduled run.

Testing

  • the_store_lock_is_free_while_the_extractor_runs: a fake FactSource sleeps 1.5 s; a search on the same Mutex completes within 800 ms while the cycle is still running.
  • a_failure_between_claim_and_store_leaves_the_batch_recoverable (server): an extractor error requeues the batch; an extractor panic after the claim leaves the lock unpoisoned and the batch extracting, and it is reclaimed and extracted after the lease.
  • Core: a_batch_abandoned_between_claim_and_store_is_claimed_again_as_the_same_batch (same source), an_extractor_failure_between_claim_and_store_releases_the_batch.
  • a_shutdown_stops_the_cycle_between_sessions, a_session_the_provider_refuses_is_tried_once_per_cycle.
  • cargo test --workspace, cargo clippy --workspace --all-targets -- -D warnings.

Closes #1663

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant