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

prefer use of InheritableThreadLocal to fix possible issue when mojo start a thread and try to access some artifacts #521

Closed

Conversation

olamy
Copy link
Member

@olamy olamy commented Aug 12, 2021

Signed-off-by: Olivier Lamy olamy@apache.org

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.

@michael-o
Copy link
Member

Merci! Do you think it is worth creating a unit test or IT to depict how it helps solving a problem?
I need to apply it to master first.

@michael-o
Copy link
Member

Issue created: MNG-7212

… when mojo starts a thread and tries to access some artifacts

Signed-off-by: Olivier Lamy <olamy@apache.org>

This closes #521
@asfgit asfgit force-pushed the maven-3.8.x_mavenProject_use_InheritableThreadLocal branch from 509aece to 8fae1d9 Compare August 12, 2021 06:39
asfgit pushed a commit that referenced this pull request Aug 12, 2021
… when mojo starts a thread and tries to access some artifacts

Signed-off-by: Olivier Lamy <olamy@apache.org>

This closes #521
@famod
Copy link
Contributor

famod commented Aug 22, 2021

I suggest to merge #527 first (since it fixes a more severe problem) and iterate on this afterwards.
I can have a look at adjusting the test I introduced in #527 that will likely fail with InheritableThreadLocal.

@famod
Copy link
Contributor

famod commented Aug 22, 2021

Btw, with this change, the orginal concurrency issue (that was addressed by #413) might come back in another form.
That is, if the spawned thread is modifying the artifact filter or the artifacts, another concurrently running thread might (again) end up with missing artifacts.
So I'm a bit on the fence about this. WDYT?

@famod
Copy link
Contributor

famod commented Aug 23, 2021

Having said the above, as long as the original problem with aggregating goals is still fixed with change (I'll check later), I think it should be ok to merge.
If plugin or extension developers modify artifacts in a new sub thread, they have basically the same problem as before the introduction of the TL, so...

@famod famod mentioned this pull request Oct 7, 2021
8 tasks
@michael-o
Copy link
Member

@olamy Can this be closed in favor of #578 since the thread local solution will be reverted?

@olamy
Copy link
Member Author

olamy commented Oct 16, 2021

@michael-o yup sure do it. #578 just introduce a very high level (unmaintainable? really needed?) complexity.
There is still no real proof this simple change is bad.
but yeah (no time for argue) so it is.

@michael-o
Copy link
Member

@michael-o yup sure do it. #578 just introduce a very high level (unmaintainable? really needed?) complexity. There is still no real proof this simple change is bad. but yeah (no time for argue) so it is.

To be honest, I cannot judge either. Can you add your opinion to #578, please? I'd really prefer to release 3.8.4 without and take more time to properly analyze the new proposal, but as you can see people only complain with releases.

@rmannibucau
Copy link
Contributor

InheritableThreadLocal works only when subclassloader tree is controlled and can accept its value leakage. It is the case for jetty but not for all mojo so iy is not a good solution neither as a generic one. 578 has soem drawback but at least monothreaded case does not involve any of the regressions seen with last releases with is the minimum expectation IMHO.

@michael-o
Copy link
Member

InheritableThreadLocal works only when subclassloader tree is controlled and can accept its value leakage. It is the case for jetty but not for all mojo so iy is not a good solution neither as a generic one. 578 has soem drawback but at least monothreaded case does not involve any of the regressions seen with last releases with is the minimum expectation IMHO.

Do you see #578 as mergeable at all or shall we seek out for a completely different solution?

@rmannibucau
Copy link
Contributor

578 gets backs to an usable state for most case with a fully functional one with 1 thread so i would merge it yes.

@michael-o
Copy link
Member

578 gets backs to an usable state for most case with a fully functional one with 1 thread so i would merge it yes.

And that superseded this PR for you?

@rmannibucau
Copy link
Contributor

Yes

@famod
Copy link
Contributor

famod commented Oct 17, 2021

I personally would prefer #476 over my PR #578 because it seems to be more efficient and catches more cases.
But I guess that #476 is a bit much of a global change for a 3.8.x? There could be a system property to opt out of it, just in case.
Anyway, if #578 is merged (for 3.8.4), #476 should be strongly considered for 3.9.0! (replacing #578)

@michael-o
Copy link
Member

michael-o commented Oct 17, 2021

I personally would prefer #476 over my PR #578 because it seems to be more efficient and catches more cases. But I guess that #476 is a bit much of a global change for a 3.8.x? There could be a system property to opt out of it, just in case. Anyway, if #578 is merged (for 3.8.4), #476 should be strongly considered for 3.9.0! (replacing #578)

Ooph, I need to digest this first. Thanks for a proper analysis.

Maybe not to merge #578 at all in 3.8.x and not add something incomplete, but rather wait for 3.9.0 for #476?
Does #476 supersede #578?

@rmannibucau
Copy link
Contributor

I would agree with #476 but didn't get much time to test but if you are confident it is better than any thread local solution anyway so happy to go with it too.

@michael-o
Copy link
Member

As far as I understood this discussion this is superseded by the two other PRs.

@michael-o michael-o closed this Oct 23, 2021
@michael-o michael-o deleted the maven-3.8.x_mavenProject_use_InheritableThreadLocal branch January 6, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants