-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNG-6843] Thread-safe artifacts in MavenProject #413
Conversation
I'm also getting this |
What error message do you get? |
CI looks the same, AFAICT. |
This likes needs an XStream update... |
@michael-o How come other PRs don't show this failure? I also had a brief look at your Jenkins jobs and I couldn't find anything there either (but I may have looked in the wrong place). I have a fix, simply updating xstream to 1.4.15 in |
PR is fine. |
Avoids concurrency issues when aggregator plugins are involved.
2eb5fa2
to
6aa1fb3
Compare
All green! 🚀 |
@michael-o So how do we move on with this? Who needs to approve? |
I would at least have @rfscholte and @khmarbaise look over. @famod Do you think an IT is possible here? |
Thanks for your quick answer.
One that is trying to provoke the concurrency issue? I fear such a test would be rather flaky... |
I guess so, that's the problem. What if one writes a sleep mojo? |
That could work, with a serious amount of effort though. Are there any exiting ITs that come with their own custom mojos? |
Yes, there are. I need search because I have touched one recently. |
@rfscholte Thanks!
Can you point me to such a test with a custom mojo? I would then try to take a (timeboxed) stab at it. |
@michael-o friendly reminder:
|
Please ping me next week, I am current incapable to do anything fruitful. Alternatively, go through Core ITs commits from me and check Plugin changes. |
@famod In your experiments, is there any case where the output of the computation of the artifacts list is not always the same for a given project ? I mean, why choosing a TLS rather than simply adding a |
Why we do it so complicated? The threads do not share their objects with ThreadLocal-s. So every Thread will see another copy. |
@gnodet @Tibor17 Have you guys read #310 (comment)? (and maybe also #310 (comment))? maven/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java Lines 280 to 283 in c3cf294
I don't see how a fine grained synchronization or a COWAL in Overhauling the (problematic) design of aggregation goal handling would be the most sustainable solution. But neither me nor the others that took a stab at this have the knowledge or capacity to do that. But even then: |
Ah, got it, thx. |
@famod |
@Tibor17 this is not a memory model problem here. The analysis done by @famod shows that when using a parallel build, multiple mojos may use the fields on the MavenProject concurrently but with different values (the artifactFilter may be different for each mojo, hence the resulting artifacts list). So synchronizing on those variables would not help, as one mojo may write a value but later read a non coherent artifacts list. The problem here is that the |
Then the usage of ThreadLocal is still wrong because one thread may see multiple Mojos. If the filter should be different for each Mojo, then it is design problem. Why to handle Mojo's variables outside? Maybe some Memento object should be apart of MavenProject. |
How could that happen ? A thread can not execute multiple mojo concurrently... |
but for me, a fix means removing the design problem |
That
A fix would require to remove the |
That was my initial thought too. But I think it does not really work, as the |
I may be wrong about the call sites, they may be inside the mojos most of the cases. |
Will check this night. |
Merged with 73e00ed |
Avoids concurrency issues when aggregator plugins are involved.
A detailed summary of the problem can be found here: #310 (comment)
Might also fix:
This is an alternative to #310 in which @rfscholte raised concerns whether cloning is the right approach.
I went with a wrapper and a single
ThreadLocal
because mutliple TLs would bloat the code and would theoretically increase overhead (haven't measured it, though).I had to be creative with removing empty lines because Checkstyle was complaining about the class exceeding 2000 lines.
PS: I removed the checklist to avoid noise (checked everything, ICLA is present).