Skip to content

fix(server): take the store mutex in separate statements so uteke-serve starts - #1786

Merged
ajianaz merged 1 commit into
developfrom
fix/serve-startup-deadlock
Nov 17, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/serve-startup-deadlock

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

What

uteke-serve v0.24.0 never starts listening. main built the request context in one let ctx = ... statement that took the Mutex<Uteke> twice. Each value is now taken in its own statement, and a new test starts the real binary and waits for GET /health.

Why

Every start of v0.24.0 stops right after the log line Lifecycle config loaded and never prints Uteke server listening. In Docker that shows as an unhealthy container (the healthcheck is curl -f /health), docker stop ends in rc=137 because PID 1 ignores SIGTERM, and the stuck process keeps the index file lock, so verify, repair and doctor block.

Cause: let ctx = ReqCtx { recall_config: Some(uteke.lock()...recall_settings().clone()), ..., remote_embeds: uteke.lock()...embed_gate().clone() }. A temporary MutexGuard lives to the end of the enclosing statement, so the first guard was still alive at the second lock(), and a std Mutex is not reentrant. v0.23.0 had recall_config: Some(engine.recall.clone()) with no lock. The first lock came from #1754, the second from #1753; each is fine alone. develop has the same code.

It is not the index lock path: acquire_file_lock and the in-memory fallback are identical in v0.23.0 and v0.24.0.

How

recall_config and remote_embeds are read into locals, each in its own statement, before let ctx. No behaviour change besides the server starting.

New test crates/uteke-server/tests/startup_listens.rs: spawns CARGO_BIN_EXE_uteke-serve on a free port with an empty data dir and an external embedder pointed at a closed port (no ONNX runtime, no model), and waits up to 60 s for GET /health to answer 200. It reports the server log if the process exits or never answers.

Testing

  • cargo test --workspace passes (not run: the workspace with default features; run on the touched package below, CI runs the rest)
  • cargo test -p uteke-server --no-default-features --features vecq: 285 tests pass (42 lib, 232 bin, 3 + 7 integration, 1 new)
  • cargo fmt --all -- --check passes
  • cargo clippy -p uteke-server --all-targets --no-default-features --features vecq -- -D warnings passes
  • Cora review run locally (not run; relying on the CI Cora job)
  • The new test fails without the fix (60 s timeout, log ends at "Lifecycle config loaded") and passes with it (0.11 s)
  • Same environment, empty data dir: v0.23.0 answers /health 200, v0.24.0 hangs (twice), v0.24.0 plus this fix answers 200. The hung process is single-threaded, 0% CPU, waiting on a futex; as PID 1 of its own namespace it ignores SIGTERM and dies on SIGKILL
  • Smoke test of the built binaries with a deterministic fake embedder: uteke CLI 18/18 commands (remember, recall, search, list, stats, context, doctor, verify, export, repair, namespace, room, tags), uteke-mcp over stdio 9/9 (57 tools, remember, recall, stats, isError:true on a missing id), uteke-serve 20/20 routes with a token (auth 401, host guard 403, 400 and 404 error classes, room and doc routes, and the embedding gate answers 429 to the third and fourth parallel hybrid search)
  • Static scan of 208 source files for a second lock() or write() on the same receiver inside one statement, or inside an if let / match / while let header and its block: only this one

Related Issues

Affects v0.24.0 (released 2026-11-13). Introduced by #1754 and #1753. A patch release needs the owner's approval of the version.

Checklist

  • Branch name follows convention (fix/)
  • Branch is from develop (at cefcf0a)
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR (no mixed concerns)

Not covered: the same build with default features (usearch plus vecq) was not run locally, CI does that. The static scan is a heuristic; it does not follow a lock held across a function call.


Generated by Claude Code

…ve starts

uteke-serve v0.24.0 stopped after 'Lifecycle config loaded' and never
listened. main built the request context in one 'let ctx = ...' statement
that took the Mutex<Uteke> twice (the [recall] defaults from #1754 and the
embedding gate from #1753). A temporary MutexGuard lives to the end of the
statement, so the second lock() waited on the first forever.

Take each value in its own statement. Add a test that starts the real
uteke-serve on an empty store and waits for GET /health; it fails (hangs at
startup) without the fix and passes with it.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 90690a6 into develop Nov 17, 2026
15 checks passed
ajianaz added a commit that referenced this pull request Nov 17, 2026
Patch release for the uteke-serve startup hang in 0.24.0 (#1786), plus the
remote document search query bound (#1777).

Version in the workspace Cargo.toml, the internal deps of uteke-core, cli,
mcp and server, Cargo.lock, both skill copies, server.json,
gemini-extension.json, docs/core-contract.json (regenerated with docgen),
docs/docker.md and docs/install.md. CHANGELOG entry with a correction to the
0.24.0 notes: a 0.23.0 binary refuses a schema v26/v27 store.

Co-authored-by: ajianaz <[email protected]>
@ajianaz ajianaz mentioned this pull request Nov 17, 2026
10 of 12 tasks
ajianaz added a commit that referenced this pull request Nov 17, 2026
Patch release. uteke-serve 0.24.0 never started listening (#1786), the remote document search query is bounded (#1777), plus docs. No schema change. See CHANGELOG.md for 0.24.1.
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.

1 participant