Skip to content

Conversation

@mmusgrov
Copy link
Member

@mmusgrov mmusgrov commented Dec 10, 2025

jbosstm/narayana-proposals#3
https://issues.redhat.com/browse/JBTM-4023

JDK17 JDK21 JDK25
CORE

The proposal explains what the PR is adding but briefly it adds support for:

  • JEP 444: Virtual Threads
  • JEP 238: Multi-Release Jar Files

and uses these features to re-implement narayana support for asynchronously preparing participants.

I've staged the implementation in three commits:

  1. Isolates the thread operations for async operations needed by BasicAction to just TwoPhaseCommitThreadPool (this is to simplify ongoing support for Multi-Release Jars (ie it contains the only differences needed for java 17 and 21) and adds tests for the functionality being replaced in commit 2.
  2. Modifies BasicAction to use this modified TwoPhaseCommitThreadPool (and removes AsyncPrepare and AsyncCommit since their functionality is replaced by two new methods added to TwoPhaseCommitThreadPool.
  3. Adds the Multi-Release jar support and modifies the tests added in commit 1 to validate that virtual threads are being used.

* Copyright The Narayana Authors
* SPDX-License-Identifier: Apache-2.0
*/
package com.arjuna.ats.arjuna.coordinator;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the java21 folder intended for java 21+ use only? @mmusgrov

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a name for a source root but should be indicative that it's for use with at least java 21.

Copy link
Member Author

@mmusgrov mmusgrov Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If later on we need specific code, for say JEP 505: Structured Concurrency (Fifth Preview), then we'd create a new source root such as src/main/java25/, which I'm sure we can find uses for :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for clarifying

@mmusgrov mmusgrov force-pushed the JBTM-4023 branch 3 times, most recently from d0e9e8c to 645cd29 Compare December 11, 2025 16:26
*
* @throws Error JBTM-895 tests, byteman limitation
*/
protected final void explicitPhase2Commit (BasicAction theAction, boolean reportHeuristics)
Copy link
Member

@tomjenkinson tomjenkinson Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC from a different part of the discussion, it would perhaps be appropriate to not have this reportHeuristics argument (and the similar one in explicitPhase2Abort) and just force false on phase2Commit and phase2Abort like we do in the newly deprecated AsyncCommit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So would we want to disallow a future usage where a feature wants to synchronously call doCommit with an explicit BasicAction which seems like a potentially useful thing to do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I guess such a user would be making changes to BasicAction anyway an could add it back in again if the need were ever to arise. I'll remove the argument.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose looking at it from that point then the answer is possibly no? But that being said it's a bit more than synchronously calling doCommit. I looked if we might be able to change our existing use of phase2Commit to this new method but I suppose we shouldn't because it would be adding extra calls to handling ThreadActionData. So I think your question is more like would we want to disallow a future usage where a feature wants to synchronously call doCommit with an explicit BasicAction and where they want to manipulate the ThreadActionData stack at the same time - that feels a more narrow use case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although then it's not obvious why reportHeuristics is being forced to be false unless the reader analyses the usages of explicitPhase2Commit and explicitPhase2Abort.

Copy link
Member Author

@mmusgrov mmusgrov Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest commit) removes the reportHeuristics arguments to explicitPhase2Commit and explicitPhase2Abort

*
* @throws Error JBTM-895 tests, byteman limitation
*/
protected final void explicitPhase2Commit (BasicAction theAction, boolean reportHeuristics)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose looking at it from that point then the answer is possibly no? But that being said it's a bit more than synchronously calling doCommit. I looked if we might be able to change our existing use of phase2Commit to this new method but I suppose we shouldn't because it would be adding extra calls to handling ThreadActionData. So I think your question is more like would we want to disallow a future usage where a feature wants to synchronously call doCommit with an explicit BasicAction and where they want to manipulate the ThreadActionData stack at the same time - that feels a more narrow use case.

@mmusgrov
Copy link
Member Author

So I think your question is more like would we want to disallow a future usage where a feature wants to synchronously call doCommit with an explicit BasicAction and where they want to manipulate the ThreadActionData stack at the same time - that feels a more narrow use case.

I called it explicitPhase2Commit because the context (BasicAction) is being passed explicitly (like we do with models like REST-AT and JTS) and on that basis manipulating the ThreadActionData stack is the intent behind the method. But I don't mind removing it since a second version of explicitPhase2Commit could be added if such a use case was ever called for.

Separately, thanks for approving but I may need a config option: while writing a benchmark I have found it necessary to add an option to enable/disable virtual threads in order to get the comparison (similar to what you asked about](https://github.com/jbosstm/narayana-proposals/pull/3/changes#r2580268195) in your review of the proposal but I need it at runtime. However, the change isn't safe while TwoPhaseCommitThreadPool is in use by BasicAction so I won't be able to commit it. But I will need the option to set it at boot time for benchmarking comparisons which would imply a change to the proposal.

@mmusgrov
Copy link
Member Author

Separately, thanks for approving but I may need a config option: while writing a benchmark I have found it necessary to add an option to enable/disable virtual threads in order to get the comparison (similar to what you asked about](https://github.com/jbosstm/narayana-proposals/pull/3/changes#r2580268195) in your review of the proposal but I need it at runtime.

I added the config option.

@mmusgrov mmusgrov added the Hold label Dec 15, 2025
@mmusgrov
Copy link
Member Author

I noticed a sporadic failure of AtomicActionAsyncTest.testRegistrationDuringCompletion on my laptop so I added the Hold label while I investigate.

@mmusgrov mmusgrov removed the Hold label Dec 17, 2025
arjPropertyManager.getCoordinatorEnvironmentBean().getMaxTwoPhaseCommitThreads());
}

public static boolean isUsingVirtualThreads() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you definitely OK with this and restartExecutor being in the public API? They look like they are used by the test but maybe you anticipate a use case for business logic to need it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. I will create another package, matching the pools package name, for just the restart test .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isUsingVirtualThreads call is harmless and potentially useful to third parties though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we do need the close and restart functionality for graceful shutdown and restart.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the last push I made the access modifier for TwoPhaseCommitThreadPool.restartExecutor less permissive and used method handles to call it from the test, I also removed the isUsingVirtualThreads and getExecutorClassName methods from the same class.

And I've squashed the similar commits - the only other one that I would have like to squash was the one about not passing the heuristic reporting flag when running async, SHA b65a00f, it contained too many conflicts. The remaining commits contain mostly self-contained modifications which may be useful for future forensic activities. TwoPhaseCommitThreadPool is changed in more than one commit but it would be quite difficult
to pull just those out into a separate commit.

@mmusgrov
Copy link
Member Author

FYI I tested the last commit using:

$ for i in $(seq 1 200); do echo "$i"; mvn test -Dtest=AtomicActionAsyncTest || break; done

which would fail quite early on in the loop without that last commit.

);
}

static void submitJob(java.util.function.Consumer<Boolean> func, boolean reportHeuristics) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer use this so I'll remove it.

Copy link
Member

@tomjenkinson tomjenkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all you need to do is remove the the method that you have identified is not used then my approval still stands after that is removed

@mmusgrov mmusgrov added the Hold label Dec 18, 2025
@mmusgrov
Copy link
Member Author

I've added the Hold label while I investigate the java 25 failure (the test run isn't choosing the correct version of the TwoPhaseCommitThreadPool class).

@mmusgrov
Copy link
Member Author

@tomjenkinson The tests are passing now. The earlier failure on the jdk 25 axis was because the surefire plugin wasn't using the java 25 specific version of TwoPhaseCommitThreadPool. I fixed it using maven profiles by defining a separate maven surefire plugin configuration which is activated when testing with java 25, and similarly for java 21 and java 17. The details are in the last commit (SHA ab8af5e JBTM-4023 update poms for testing multi-release jars).

The tests on as_builder (17) passed but the builder failure happened on the "Save Narayana Maven repository" step:

Error: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run

@tomjenkinson
Copy link
Member

Very nice! Thank you!

@tomjenkinson
Copy link
Member

I re-approved it but please note the JDK 17 failure

@mmusgrov
Copy link
Member Author

mmusgrov commented Jan 12, 2026

I re-approved it but please note the JDK 17 failure

The tests on as_builder (17) passed but the builder failure happened on the "Save Narayana Maven repository" step:

Error: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run

I'd say it's a GH Action issue, do you have any thoughts about that @jmfinelli

@tomjenkinson
Copy link
Member

The JDK double as_builder thing will hopefully be fixed by #2462

@mmusgrov
Copy link
Member Author

@mmusgrov mmusgrov merged commit ccd7406 into jbosstm:main Jan 12, 2026
66 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants