[JIRA] (JENKINS-57774) JenkinsRule: Jetty leaves stray threads running after server.stop()

13 views
Skip to first unread message

sharmaabhyudaya@gmail.com (JIRA)

unread,
May 30, 2019, 11:50:02 PM5/30/19
to jenkinsc...@googlegroups.com
Abhyudaya Sharma created an issue
 
Jenkins / Bug JENKINS-57774
JenkinsRule: Jetty leaves stray threads running after server.stop()
Issue Type: Bug Bug
Assignee: Oliver Gondža
Attachments: threads_report.txt
Components: jenkins-test-harness
Created: 2019-05-31 03:49
Priority: Minor Minor
Reporter: Abhyudaya Sharma

 
I was debugging through JenkinsRule from Jenkins Test Harness. After the Jetty server and Jenkins have both been terminated in JenkinsRule#after() (line 488 and line 502, respectively) stray threads keep running. Attached is the dump of the running threads. Is it possible to terminate these threads to allow the JVM to exit gracefully?
 
This issue may already have been reported before in this Stack Overflow question: https://stackoverflow.com/questions/13769007/jetty-server-leaves-behind-threads-after-stop
 
A minimal example would be following test code and setting a breakpoint at the System.gc() call on line 517:
 
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class RandomTest {
    @Rule
    public JenkinsRule jenkinsRule = new JenkinsRule();

{{    @Test
    public void randomTest() {         System.out.println("Hello world");     }
}
}}
 
I was able to confirm the behaviour with the latest Jetty on both Windows 10 and Linux.
 
This issues was discussed on the developer mailing list: https://groups.google.com/forum/#!topic/jenkinsci-dev/7yL0MKjxQwA

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

jglick@cloudbees.com (JIRA)

unread,
May 31, 2019, 10:24:02 AM5/31/19
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
Change By: Jesse Glick
 
I was debugging through JenkinsRule from Jenkins Test Harness. After the Jetty server and Jenkins have both been terminated in JenkinsRule#after() ([line 488|https://github.com/jenkinsci/jenkins-test-harness/blob/2281a68194604c983e7a8d1e7822379b262f153d/src/main/java/org/jvnet/hudson/test/JenkinsRule.java#L488] and {color:#000020}[line 502|https://github.com/jenkinsci/jenkins-test-harness/blob/2281a68194604c983e7a8d1e7822379b262f153d/src/main/java/org/jvnet/hudson/test/JenkinsRule.java#L502]{color}, respectively) stray threads keep running. Attached is the dump of the running threads. Is it possible to terminate these threads to allow the JVM to exit gracefully?

 
This issue may already have been reported before in this Stack Overflow question: [https://stackoverflow.com/questions/13769007/jetty-server-leaves-behind-threads-after-stop]
 
A minimal example would be following test code and setting a breakpoint at the System.gc() call on line 517:
 
{ color:#660066 code } {color:#004000}
import org.junit.Rule;
{color}{color}
{color:#660066}{color:#004000}
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

{color}{color}
{color:#660066}{color:#004000}
public class RandomTest {
    @Rule
    public JenkinsRule jenkinsRule = new JenkinsRule();

{color}{color}
{{{color:#660066}{color:#004000}   
@Test
    public void randomTest() {
        System.out.println("Hello world");
    }
}

{ color code } {color}}}
 
I was able to confirm the behaviour with the latest Jetty on both Windows 10 and Linux.
 
This issues was discussed on the developer mailing list: {color:#004000}https://groups.google.com/forum/#!topic/jenkinsci-dev/7yL0MKjxQwA{color}

jglick@cloudbees.com (JIRA)

unread,
May 31, 2019, 10:25:01 AM5/31/19
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-57774
 
Re: JenkinsRule: Jetty leaves stray threads running after server.stop()

Is there a concrete problem this behavior is causing? mvn test failures, etc.?

olamy@apache.org (JIRA)

unread,
Jun 3, 2019, 12:37:03 AM6/3/19
to jenkinsc...@googlegroups.com

can you please provide a project with a pom. To know which version you are using.

And yes last but not least what is the real problem?

 

sharmaabhyudaya@gmail.com (JIRA)

unread,
Jun 3, 2019, 12:57:02 AM6/3/19
to jenkinsc...@googlegroups.com

Hi. I'm working creating a framework to benchmark Jenkins using Java Microbenchmark Harness. To do that, I'm starting a Jenkins instance similar to how it is done by JenkinsRule. When the instance  is terminated (after the benchmark has completed) using server.stop() and Jenkins.cleanup(), these threads keep running and cause JMH to wait and later forcefully kill the JVM.

This has been implemented in Role Strategy Plugin so the pom is: https://github.com/jenkinsci/role-strategy-plugin/blob/master/pom.xml

However, I did manually update all of the Jetty dependencies to the latest version and I was able to observe it again.

 

sharmaabhyudaya@gmail.com (JIRA)

unread,
Jun 3, 2019, 1:06:04 AM6/3/19
to jenkinsc...@googlegroups.com
Abhyudaya Sharma edited a comment on Bug JENKINS-57774
Hi. I'm working creating a framework to benchmark Jenkins using Java Microbenchmark Harness. To do that, I'm starting a Jenkins instance similar to how it is done by JenkinsRule. When the instance  is terminated (after the benchmark has completed) using server.stop() and Jenkins.cleanup(), these threads keep running and cause JMH to wait and later forcefully kill the JVM.

This has been implemented in Role Strategy Plugin so the pom is: [https://github.com/jenkinsci/role-strategy-plugin/blob/master/pom.xml]

However, I did manually update all of the Jetty dependencies to the latest version and I was able to observe it again :

 
#
{code:java}
<project xmlns="http://maven
. apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jenkins-ci.plugins</groupId>
        <artifactId>plugin</artifactId>
        <version>3.43</version>
    </parent>

    <artifactId>role-strategy</artifactId>
    <packaging>hpi</packaging>
    <version>${revision}${changelist}</version>
    <name>Role-based Authorization Strategy</name>
    <url>https://wiki.jenkins.io/display/JENKINS/Role+Strategy+Plugin</url>

    <scm>
        <connection>scm:git:ssh://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
        <developerConnection>scm:git:ssh://g...@github.com/jenkinsci/${project.artifactId}-plugin.git</developerConnection>
        <url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
      <tag>${scmTag}</tag>
  </scm>

    <developers>
        <developer>
            <id>tmaurel</id>
            <name>Thomas Maurel</name>
            <timezone>+1</timezone>
        </developer>
        <developer>
            <id>rseguy</id>
            <name>Romain Seguy</name>
            <timezone>+1</timezone>
        </developer>
        <developer>
            <name>Oleg Nenashev</name>
            <id>oleg_nenashev</id>
            <email>o.v.ne...@gmail.com</email>
        </developer>
    </developers>

    <properties>
        <revision>2.12</revision>
        <changelist>-SNAPSHOT</changelist>
        <jenkins.version>2.60.3</jenkins.version>
        <java.level>8</java.level>
        <configuration-as-code.version>1.17</configuration-as-code.version>
    </properties>

    <repositories>
        <repository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://www.opensource.org/licenses/mit-license.php</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <dependencies>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>matrix-auth</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-junit</artifactId>
            <version>2.0.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>cloudbees-folder</artifactId>
            <version>6.1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>jquery</artifactId>
            <version>1.11.2-0</version>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>jquery-ui</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>1.21</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <version>1.21</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.jenkins</groupId>
            <artifactId>configuration-as-code</artifactId>
            <version>${configuration-as-code.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.jenkins</groupId>
            <artifactId>configuration-as-code</artifactId>
            <version>${configuration-as-code.version}</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.reflections</groupId>
            <artifactId>reflections</artifactId>
            <version>0.9.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty.websocket</groupId>
            <artifactId>websocket-api</artifactId>
            <version>9.4.18.v20190429</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty.websocket</groupId>
            <artifactId>websocket-client</artifactId>
            <version>9.4.18.v20190429</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>9.4.18.v20190429</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <version>9.4.18.v20190429</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-security</artifactId>
            <version>9.4.18.v20190429</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>9.4.18.v20190429</version>
        </dependency>
    </dependencies>

    <profiles>
        <!-- Profile to run benchmarks when the `benchmark` property is set -->
        <profile>
            <id>jmh-benchmark</id>
            <activation>
                <property>
                    <name>benchmark</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
                     <configuration>
                     <includes>
                     <include>**/*Benchmark.java</include>
                     <include>**/Benchmark*.java</include>
                     </includes>
                     </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

{code}

 

 
Reply all
Reply to author
Forward
0 new messages