Skip to content

fix(server): take the remote embedding slot before the store lock - #1747

Merged
ajianaz merged 1 commit into
developfrom
test/onnx-doc-skill-routes
Nov 12, 2026
Merged

ajianaz merged 1 commit into
developfrom
test/onnx-doc-skill-routes

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

What

The router takes the slot of the remote embedding guard (POST /doc/similar with a draft text, POST /skill/similar with a text, POST /skill/search in hybrid/semantic mode) before it locks the store. The gate is a new ReqCtx::remote_embeds (a clone of EmbedGate, now Clone). An oversized draft is answered with a 400 in the router, before the slot is taken. check_draft_len is now a free function in remote_guard. The Uteke gate stays for non-server callers (MCP).

Why

uteke serve runs a request under the store lock, one at a time, so the gate taken inside the handler never saw a second request and the 429 could not happen over HTTP. Checked with the real embeddinggemma-300m model: 20 parallel /skill/similar requests with distinct 30000-character texts all answered 200 and queued behind the lock, the slowest after 247 s. After the fix the same burst gives 2 x 200 (15.8 s and 26 s) and 18 x 429 in 3-15 ms, and a /skill/list stays responsive.

Testing

  • New the_embedding_gate_refuses_before_the_store_lock_is_taken: with the store lock held, two embedding requests wait, the third and fourth answer 429 without the lock, an oversized draft answers 400, and the slots are released.
  • New only_requests_that_embed_a_client_string_take_a_slot (which bodies take a slot).
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p uteke-server --bin uteke-serve (234 passed), cargo test -p uteke-mcp (91 passed), cargo test -p uteke-core remote_guard.
  • Real-model burst run described above (ORT 1.29, debug build).

Refs #1731

The server holds the store lock for a whole request, so the per-Uteke gate taken inside it never saw a second request and the 429 was unreachable over HTTP. Take the slot in the router before the lock, and answer an oversized draft with a 400 there.
@github-actions

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.

1 participant