-
Notifications
You must be signed in to change notification settings - Fork 119
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
handle thread interrupts on transitive dependencies parsing (infinite loop) #236
Conversation
Could you elaborate a bit more the "musquette has dependencies that in the dependencies resolving process lead to being stuck in an infinite loop"? |
Switch to BF collector and you will get an error:
Basically, the tree is not resolvable. Still, the endless loop does not sound right and is easily reproducible, just run demo snippet org.apache.maven.resolver.examples.GetDependencyTree and change artifact ctor to have string |
To switch to BF (breadth first) collector set config property like this:
|
Created bug https://issues.apache.org/jira/browse/MRESOLVER-316 This PR is -1 for me, as this would treat the symptom (stopping endless loop), while IMHO the actual cause should be addressed, and there is a workaround by using BF collector. |
Well, it's not really a "pure" maven artifact based on a java package. Will try the solution you recommend and get back. |
The snippet changes I have locally: switch to BF collector and using musquette artifact: diff --git a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/GetDependencyTree.java b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/GetDependencyTree.java
index 78af7839..050c96b8 100644
--- a/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/GetDependencyTree.java
+++ b/maven-resolver-demos/maven-resolver-demo-snippets/src/main/java/org/apache/maven/resolver/examples/GetDependencyTree.java
@@ -21,6 +21,7 @@ package org.apache.maven.resolver.examples;
import org.apache.maven.resolver.examples.util.Booter;
import org.apache.maven.resolver.examples.util.ConsoleDependencyGraphDumper;
+import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
@@ -28,6 +29,7 @@ import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.collection.CollectResult;
import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector;
/**
* Collects the transitive dependencies of an artifact.
@@ -48,9 +50,10 @@ public class GetDependencyTree
RepositorySystem system = Booter.newRepositorySystem( Booter.selectFactory( args ) );
- RepositorySystemSession session = Booter.newRepositorySystemSession( system );
+ DefaultRepositorySystemSession session = Booter.newRepositorySystemSession( system );
+ session.setConfigProperty("aether.dependencyCollector.impl", BfDependencyCollector.NAME );
- Artifact artifact = new DefaultArtifact( "org.apache.maven:maven-resolver-provider:3.6.1" );
+ Artifact artifact = new DefaultArtifact( "org.webjars.npm:musquette:1.1.1" );
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot( new Dependency( artifact, "" ) );
|
Few perf related tips (and then am out for today):
|
@cstamas Thanks a lot for your help and fast feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the same should be added to the BF collector.
I agree with @gnodet this should be handled, and not only in DF but also BF, but there is a catch: the "endless loop" did not happen where this PR changes code but in visitor (as I debugged, visitor goes into endless loop, and there is no IO happening, nor anything else) |
@cstamas So where/what changes do you suggest? |
@vfedoriv yes please, close this one, and created issue https://issues.apache.org/jira/browse/MRESOLVER-321 Just to explain:
IMO, MRESOLVER-316 even if fixed, will not make possible aborting as MRESOLVER-321 asks for, so aborting will need some spots for this spread in multiple places. |
Superseded by #380 Now both collectors are "interrupt aware" and will handle same way interruption (see UT). |
Hello.
In the scope of our project (https://central.sonatype.dev - new (beta) version of https://search.maven.org) we do parsing pom-s for transitive dependencies, using Maven Resolver.
It works fine in most cases. But recently, during the upload musquette artifact
https://repo1.maven.org/maven2/org/webjars/npm/musquette/1.1.1/
we see 100% CPU load on our service. It appears that the resolver is stuck in process of resolving transitive dependencies
The reason: this component (musquette) has dependencies that in the dependencies resolving process lead to being stuck in an infinite loop.
Here profiler graph
We run each pom file parsing in a separate thread, but have no way to interrupt parsing when it's stuck in resolver methods.
So the goal is to interrupt dependencies parsing after the thread with the parser receives an interrupt event.