[
https://issues.apache.org/jira/browse/CAMEL-27507?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27507:
--------------------------------
Fix Version/s: 4.24.0
(was: 4.25.0)
> camel-vertx-websocket - the route continues on the Vert.x event loop after a
> send, and a producer that must connect there deadlocks
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27507
> URL: https://issues.apache.org/jira/browse/CAMEL-27507
> Project: Camel
> Issue Type: Bug
> Components: camel-vertx-websocket
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> When a vertx-websocket producer sends to a remote server, the send completes
> asynchronously and the route continues on the Vert.x event loop thread
> ({{vert.x-eventloop-thread-N}}). A later vertx-websocket producer in the same
> route that needs a new connection then blocks that event loop while it waits
> for a connect that needs the same event loop: a deadlock.
> Found with the websocket-sink Kamelet test, on a main build that includes
> CAMEL-27482.
> h3. Reproducer
> One route:
> {noformat}
> timer
> -> to vertx-websocket:localhost:P/in?token=RAW(a+b&c%) (producer to a
> remote server)
> -> an http call
> -> to vertx-websocket:localhost:P/in (a DIFFERENT URI,
> so a new endpoint and connection)
> {noformat}
> * The first send completes async, and the route continues on
> {{vert.x-eventloop-thread-1}}.
> * The second producer calls {{VertxWebsocketEndpoint.getWebSocket}}, which
> blocks in {{CompletableFuture.get}} (VertxWebsocketEndpoint:313) waiting for
> the connect, which has to run on that same event loop.
> * Vert.x logs "Thread vert.x-eventloop-thread-1 has been blocked for ... ms"
> every second, and the message never arrives.
> * With the same URI twice, the connection is reused and nothing blocks.
> Stack (top = most recent):
> {noformat}
> CompletableFuture.get
> VertxWebsocketEndpoint.getWebSocket:313 / 260 / 246 / 343
> VertxWebsocketProducer.getConnectedPeers:141
> VertxWebsocketProducer.process:62
> ...
> SendProcessor$SentCallback.done
> VertxWebsocketResultHandler.onComplete:84 / onResult:51
> VertxWebsocketProducer.lambda$process$1:83
> {noformat}
> h3. Wider impact
> Any blocking step after a vertx-websocket producer (http, jdbc, ...) runs on
> the event loop and stalls the WebSocket I/O on it, even when it does not
> deadlock.
> h3. Possible direction
> * Complete the producer callback off the event loop (as the consumer does
> with {{executeBlocking}}), or
> * connect without blocking (compose the send on the connect future instead of
> {{CompletableFuture.get}}).
> _Filed by Claude Code on behalf of davsclaus._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)