Skip to content
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-7285] - Test showcasing regression #570

Closed

Conversation

mickaelistria
Copy link
Contributor

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MNG-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MNG-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@mickaelistria mickaelistria changed the title [MNG-7285 - Test showcasing regression [MNG-7285] - Test showcasing regression Oct 7, 2021
@michael-o
Copy link
Member

@famod

@@ -43,6 +43,8 @@
import org.apache.maven.shared.utils.io.FileUtils;


import junit.framework.TestResult;
Copy link
Member

Choose a reason for hiding this comment

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

where is used?

@famod
Copy link
Contributor

famod commented Oct 7, 2021

A few things:

@mickaelistria
Copy link
Contributor Author

this stopped working in 3.8.2, not 3.8.3, right?

Yes. We just noticed it in 3.8.3 because some other issues prevented m2e from adopting 3.8.2. But the test does fail starting from 3.8.2.

this specific case would be fixed by prefer use of InheritableThreadLocal to fix possible issue when mojo start a thread and try to access some artifacts #521, but I don't think this is exactly what happens in m2e because there are thread pools, right?

It depends. Eclipse Platform has a job API and some specific threads (UI, workers, monitors...). Some use thread pools, some other just pass values along known threads; but usually we cannot rely on thread inheritance. So indeed, fix #521 would not work.

I don't have a good understanding of MNG-6843 to propose a better solution, but my impression is that usage of ThreadLocal in a MavenProject is not a good idea as it can have a different lifecycle from what ThreadLocal is meant for.

@michael-o
Copy link
Member

@mickaelistria Please revert those two commits and see whether it solves the issue.

@mickaelistria
Copy link
Contributor Author

Reverting 76d5f0d (no need to revert anything else) makes the test successful.

@michael-o
Copy link
Member

Reverting 76d5f0d (no need to revert anything else) makes the test successful.

Did you also revert 4e5b3d5 because it is based on top of 76d5f0d?

@famod WDYT? Do we really need to revert your changes in master and maven-3.8.x? :-(

@mickaelistria
Copy link
Contributor Author

Did you also revert 4e5b3d5 because it is based on top of 76d5f0d?

No, just a revert of 76d5f0d was enough. I don't know how the revert happened in details, bit it seemed to work.

@famod
Copy link
Contributor

famod commented Oct 8, 2021

Well, it was the very goal of 76d5f0d to make sure that one thread cannot modify (in a non-atomic way) the artifacts of a MavenProject that another thread is working with.
As a consequence, also simply reading the artifacts (via getArtifacts()) is now isolated to the thread that set the artifacts.
All that with the fundamental design flaws of MavenProject in mind (mutability vs. concurrent access) and the limitation of not being able to do any real refactoring in a 3.x release.

It's remarkable that no one really stepped up to enforce what now seems to have come up as a general requirement, which is that all threads need to see the same artifacts.
It's also remarkable that m2e, which I consider an important "consumer" of maven core, is not really "integrated" into the maven release process.

The irony is that I myself was never really affected by MNG-6843 but by chance I stumbled upon that problem, saw how many users are affected by that, found a PR that was fixing it and merely optimized it a bit.

But let's leave the meta level again and try to focus on possible fixes or workarounds:
@mickaelistria can you point me to the m2e code where a MavenProject leaves the context of one thread and enters the context of another thread?

@famod
Copy link
Contributor

famod commented Oct 8, 2021

Btw, I might have an idea on how to solve MNG-6843 with a different approach, isolated to MojoExecutor.
It won't be pretty (if it works at all), but it should be less invasive than the TL in MavenProject (or a "proper" refactoring like #475).

@famod
Copy link
Contributor

famod commented Oct 9, 2021

#578 tries to fix MNG-6843 differently, avoiding any ThreadLocals or refactorings,

@michael-o
Copy link
Member

michael-o commented Oct 10, 2021

Can we agree that, unfortunately, @famod's solution did not work out as expected an can revert both commits in separate ticket to make it clear in the release notes first? The we can go over to @famod's new proposal.

@famod In any case, thank you very much for your dedication and time!

@famod
Copy link
Contributor

famod commented Oct 10, 2021

I don't mind in the end. But we should really avoid "un-fixing" MNG-6843 in 3.8.4.

@mickaelistria
Copy link
Contributor Author

Again, I'm not expert in MNG-6843 and family, but looking purely at the code, I find #578 less intrusive, restricting and disruptive than the previous related patches, so if #578 receives positive reviews in a decent timeframe, I'd find it OK to just merge it without reverting anything.

@mickaelistria
Copy link
Contributor Author

Was a similar test included with some other commit? If so, should this be closed now?

@gnodet
Copy link
Contributor

gnodet commented Dec 8, 2021

This test has been integrated into #627 and #628.

@gnodet gnodet closed this Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants