Servlet transports block Tomcat thread
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Inizia con HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider e HttpServletStatelessServerTransport, tracciando dove le richieste in ingresso chiamano .block() e come viene utilizzato AsyncContext. Confronta i percorsi di SyncToolSpecification e AsyncToolSpecification, quindi verifica che i thread delle richieste vengano rilasciati mentre l’operazione reattiva continua e si completa correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
All Servlet-based transports in the SDK (e.g., HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider, HttpServletStatelessServerTransport) call .block() on the Tomcat request thread when processing incoming HTTP requests.
Although AsyncContext is used to hold connections for SSE/streaming, the Tomcat thread remains parked until tool execution completes. As a result, the reactive/async architecture does not provide any real thread efficiency: the request thread stays blocked for the entire duration of the tool call.
With SyncToolSpecification and immediateExecution=false, the tool handler is executed on a separate thread (typically from the boundedElastic pool). This prevents blocking logic from running on the Tomcat thread itself, but the request thread still remains blocked waiting for completion.
With AsyncToolSpecification(via McpAsyncServer), handlers are expected to return fully asynchronous operations (e.g., non-blocking I/O). However, because the transport calls .block(), the HTTP request handling remains synchronous. The handler is not automatically scheduled on another thread unless the developer explicitly does so.
As a result, both SyncToolSpecification and AsyncToolSpecification ultimately block the Tomcat request thread until completion.
I’m not sure if this behavior is intentional. Based on the design of McpAsyncServer, I would expect the transport layer to release the Tomcat thread immediately and allow the reactive pipeline to complete asynchronously. (AsyncContext + subscribe).
@pratik2294
- Lingua principale
- Java
- Stelle
- 3.7k
- Fork
- 1.1k
- Merge medio
- 1g 15h
- PR unite (30g)
- 9
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/java-sdk
-
area/transport bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelcontextprotocol/java-sdk#1124 · 1 commento ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Apertabug P2 ready for work
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/java-sdk#1086 · 1 commento ·
-
enhancement good first issue P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
modelcontextprotocol/java-sdk#898 · 1 commento ·
Tutte le issue di modelcontextprotocol/java-sdk
Issue simili
-
Bug Java Platform: Java
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/sentry-java#6138 · 1 commento ·
-
bug needs triage p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 commento ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/rocketmq-dashboard#4654 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100