Servlet transports block Tomcat thread
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
Piste de recherche
Commencez par HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider et HttpServletStatelessServerTransport, en suivant les endroits où les requêtes entrantes appellent .block() et la manière dont AsyncContext est utilisé. Comparez les chemins de SyncToolSpecification et AsyncToolSpecification, puis vérifiez que les threads des requêtes sont libérés tandis que l’opération réactive se poursuit et se termine avec succès.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Java
- Étoiles
- 3.7k
- Forks
- 1.1k
- Merge moyen
- 1 j 15 h
- PR mergées (30 j)
- 9
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/java-sdk
-
area/transport bug P2
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
modelcontextprotocol/java-sdk#1124 · 1 commentaire ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Ouvertebug P2 ready for work
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
modelcontextprotocol/java-sdk#1086 · 1 commentaire ·
-
enhancement good first issue P3
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
modelcontextprotocol/java-sdk#898 · 1 commentaire ·
Toutes les issues de modelcontextprotocol/java-sdk
Issues similaires
-
Bug Java Platform: Java
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
getsentry/sentry-java#6138 · 1 commentaire ·
-
bug needs triage p2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 commentaire ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/rocketmq-dashboard#4654 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100