Repository navigation
Conversation
7d067d4 to
6c733f4
Compare
6c733f4 to
62abafa
Compare
|
2 items to address (runner termination on task failure, and explicit false vs the system property default), the rest looks good. |
62abafa to
8a13d26
Compare
jeanouii
left a comment
There was a problem hiding this comment.
Thanks Matt — both items addressed
| Thread.currentThread().interrupt(); | ||
| } catch (Throwable t) { | ||
| LOG.error("Virtual Thread task runner terminating on unexpected error: {}", task, t); | ||
| throw t; |
There was a problem hiding this comment.
Looking at the left side I think this can behave differently.
throw t will terminate the thread right? So the next wakup() won't do anything.
Previously the runner would requeue after a failure and therefor recover if I'm correct.
| private final AtomicBoolean initDone = new AtomicBoolean(false); | ||
| private int maxThreadPoolSize = getDefaultMaximumPoolSize(); | ||
| private RejectedExecutionHandler rejectedTaskHandler = null; | ||
| /** system property that turns on virtual thread task runners for every factory that is not told otherwise */ |
There was a problem hiding this comment.
Line 112: similar to another PR for failover it would not work. You would need a Boolean to have 3 states
|
LGTM |
|
I ran this through an AI audit for a sanity check and it reported 4 things to look into: Reviewed 8a13d26 [P1] Closing an async session leaves its virtual dispatch thread parkedVirtualThreadTaskRunner.java:149–153 ActiveMQSession.dispose() closes the dispatch queue and removes the session without shutting down its runner. The parked worker then misses the connection’s session-stop pass, and orderly executor shutdown does not interrupt it. Repeatedly opening and closing async sessions can leave one parked worker per session that started dispatch. Shut down the runner during session disposal. [P2] A listener that restores its interrupt flag can permanently stall dispatchVirtualThreadTaskRunner.java:151–159 If a message listener restores its interrupt flag and returns, the next idle await() throws and the worker exits. Subsequent wakeups signal a condition with no worker to receive them. Keep the runner available for future deliveries unless shutdown was requested. [P2] The global virtual-thread flag can starve sessions on an injected executorTaskRunnerFactory.java:177–183 ( The effective flag now selects the persistent runner even when setExecutor() supplied the executor. With an injected single-thread pool, the first session holds the only worker even while idle, so a second session cannot dispatch. Preserve pooled runners for injected executors unless thread-per-task execution is explicitly supported. [P2] The field type change breaks deserialization of existing connection factoriesActiveMQConnectionFactory.java:163–164 Changing this instance field from boolean to Boolean changes the computed serialVersionUID. ActiveMQConnectionFactory implements Externalizable and has no explicit UID, so an older stream is rejected before readExternal() can read its properties. Declare the pre-change UID and test deserialization of a fixture written by the previous version. |
|
@jeanouii - For the last report finding, about serialization, I wouldn't think it would be very common to serialize a Connection factory but it does support the Externalization interface, but I suppose it's possible. |
|
I pushed up a proposed commit with the fixes and tests: https://github.com/cshannon/activemq/tree/fix/pr-2866-review 525e322 fixes finding 1 (P1): closing an async JMS session leaves its dispatch thread parked. It shuts down the session’s runner on close, covering both the pre-existing dedicated-thread leak and the virtual-thread leak introduced by this PR The other three findings are fixed in bf487b1. |
…ixes One long-lived virtual thread per TaskRunner that parks between work, replacing the thread per wakeup submission, with termination logged on unexpected errors. No-arg shutdown() waits for the running iteration, matching the pooled and dedicated runners. Client-side fixes: load the java21 classes through this artifact's own class loader so client factories work without setThreadClassLoader, honor the system property in task runner selection the same as in executor setup, create the failover reconnect task on first use so the virtual thread setting reaches it, propagate the connection factory flag to the failover transport, and keep the task runner settings across serialization and JNDI. Tests: task runner behavior (thread identity, wakeup delivery, shutdown bounds and contract, failure logging, thread release) run through both the factory flag and the system property, the client configuration precedence matrix, session dispatch and failover reconnect on both thread types.
Close the dispatch queue and detach its runner under the same lock used for runner creation. Signal shutdown without waiting indefinitely while session disposal holds locks that a listener may need. Verify that an idle dedicated runner exits when its session closes, while the connection is still open. (cherry picked from commit 525e322)
Stop session runners on close and keep dispatch alive when a listener restores its interrupt status. Use pooled runners with injected executors so idle sessions do not monopolize bounded pools. Preserve the connection factory serialization UID and cover deserialization with a fixture from before the virtual thread changes. (cherry picked from commit bf487b1)
8a13d26 to
5dd1549
Compare
|
@cshannon I cherry-picked your commits to the branch. |
Background
First iteration of Virtual Thread task runner created a VT per-wakeup. This moves to create a VT per-Task and is more inline with how the other runners work. This is specifically shows improvement for fast ack'n non-persistent consumers.
ref: client-side fixes was in previous PR [#2766]