Repository navigation
fix(server): take the remote embedding slot before the store lock - #1747
Merged
Merged
Conversation
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.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Nov 12, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The router takes the slot of the remote embedding guard (
POST /doc/similarwith a drafttext,POST /skill/similarwith atext,POST /skill/searchinhybrid/semanticmode) before it locks the store. The gate is a newReqCtx::remote_embeds(a clone ofEmbedGate, nowClone). An oversized draft is answered with a 400 in the router, before the slot is taken.check_draft_lenis now a free function inremote_guard. TheUtekegate stays for non-server callers (MCP).Why
uteke serveruns 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/similarrequests 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/liststays responsive.Testing
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.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.Refs #1731