Repository navigation
Conversation
Build status (run 44130930369, commit 80c854a)JDK 21 - SUCCESS - 33 modules (0 cached, 33 built) in 22:34Per-module details
JDK 25 - SUCCESS - 33 modules (0 cached, 33 built) in 23:42Per-module details
|
7abf16d to
b60a259
Compare
b60a259 to
2c6afe0
Compare
smcvb
left a comment
There was a problem hiding this comment.
Frankly a bit in doubt whether to request changes yes or no. The added util makes sense to me, although I can imagine it's better situated in Axon Framework. But more importantly, the LLM-concern raised on the CallbackHandOff#handOff method is something we should look into.
| * @throws NullPointerException if {@code task} is {@code null} | ||
| */ | ||
| public static Runnable handOff(Runnable task) { | ||
| return handOff(Thread::startVirtualThread, task); |
There was a problem hiding this comment.
Potential helpful LLM-based comment I am leaving as is:
Curious: how does this behave on JDK 21 with the
synchronizeddrains?IncomingQueryInvoker.drain()andSpringCloudQueryBusConnector.drain(source)aresynchronizedand do blocking I/O (sink.response(...)) inside the monitor. On JDK 21 a virtual thread that blocks insidesynchronizedpins its carrier, so a slow SSE client could occupy carrier threads, which is what we're trying to avoid for the producer threads. Either use aReentrantLockin those drains, or tell me why pinning is acceptable here.
There was a problem hiding this comment.
I've changed it to use a ReentrantLock, but I think in this case it wouldn't matter that much. The nasty cases are when a thread is pinned, but it is waiting for another thread that needs a pinned resource.
| @@ -368,21 +371,18 @@ private synchronized void drain() { | |||
| return; | |||
There was a problem hiding this comment.
Another LLM-pointer I am leaving as is:
Same point as on
CallbackHandOff:drain()issynchronizedand writes to the sink (blocking I/O) while running on a virtual thread, which pins its carrier on JDK 21.
| * them draining the same source would take entries out from under each other. | ||
| */ | ||
| private void drain(Source source) { | ||
| synchronized (source) { |
There was a problem hiding this comment.
Same synchronized question as on the IncomingQueryInvoker applies here.
| try { | ||
| task.run(); | ||
| } catch (RuntimeException e) { | ||
| logger.error("A task handling a signal from a message stream failed.", e); |
There was a problem hiding this comment.
Nothing of this class dictates it's used by a MessageStream, right? If you agree, can we adjust the logging such to not refer to "message stream" exactly?
| * Returns as soon as the query has been handed to the local handler. Responses are written to the {@code sink} as | ||
| * the handler produces them, which for a handler that answers asynchronously is after this method returned. | ||
| * Returns as soon as the query has been handed to the local handler. The responses are written to the | ||
| * {@code sink} on another thread, as and when the handler's stream has them, so after this method returned. |
There was a problem hiding this comment.
I don't understand this new sentence at all. Care to reword it? 🙏
2c6afe0 to
63ac5c3
Compare
The connectors read from a response stream inside its callback, which runs on the thread of whoever produced the response. That thread is shared with other streams, so the read can stall them, and Axon Framework is going to reject it. The callback now only schedules the drain, through the new CallbackHandOff, which combines signals and runs the work on a virtual thread. The drain that followed registering the callback is gone, as a stream calls back at once when it already has something. This also removes a lock-order inversion between the connector's lock and the stream's lock. Tests that expected the drain to run synchronously now wait for it.
63ac5c3 to
80c854a
Compare
I didn't want to make another cross dependency for merge ordering... frankly I was considering not even making a utility at all. It is marked |
Merge this before AxonIQ/AxonFramework#5251. That change makes streams reject reads from their callback, which
FlowControlledResponseSender,IncomingQueryInvokerandSpringCloudQueryBusConnectordo today. This change works with and without it.CallbackHandOffinaxoniq-distributed-messagingreturns a stream callback that only schedules the work. Signals that arrive before the work starts share one run, and it runs on a virtual thread, or on a givenExecutor.