Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57725

Proc.executor inherits ContextClassLoader dynamically

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • Jenkins 2.181

      The threads in the thread pool used for Proc.joinWithTimeout inherit their context class loader from the thread that calls Proc.joinWithTimeout, which seems undesirable. While looking into JENKINS-50223, I found a case where one of the threads in the thread pool was holding onto a CleanGroovyClassLoader class loader from workflow-cps (see the attached screenshot), which is definitely undesirable.

      We should wrap this thread pool in ClassLoaderSanityThreadFactory to prevent this kind of issue from happening.

          [JENKINS-57725] Proc.executor inherits ContextClassLoader dynamically

          Devin Nusbaum created issue -
          Devin Nusbaum made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Devin Nusbaum made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Devin Nusbaum made changes -
          Remote Link New: This issue links to "jenkinsci/jenkins#4035 (Web Link)" [ 23028 ]
          Oleg Nenashev made changes -
          Released As New: Jenkins 2.181
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]
          Oleg Nenashev made changes -
          Labels New: lts-candidate
          Oliver Gondža made changes -
          Labels Original: lts-candidate New: 2.176.2-fixed
          Kyle made changes -
          Attachment New: Screenshot from 2019-07-22 15-35-03.png [ 48051 ]

          Kyle added a comment - - edited

          This was mentioned in the LTS changelog for v2.176.2, but I'm experiencing something related.  My Jenkins system with 20 executors will creep towards 20k Tasks (processes + threads) before it hits the systemd imposed DefaultTasksMax limit of 19660 on my system.

           

           A java heap dump shows that  4675 of the total 4877 match the expression Timer-.* and have the Context Class Loader-> org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$CleanGroovyClassLoader.


           

           Bottom right corner of my Jenkins UI confirms I'm running the latest version (Jenkins ver. 2.176.2)with all plugins updated on OpenJDK Runtime Environment (build 1.8.0_222-b05) with. Ubuntu 18.04

          Kyle added a comment - - edited This was mentioned in the  LTS changelog for v2.176.2 , but I'm experiencing something related.  My Jenkins system with 20 executors will creep towards 20k Tasks (processes + threads) before it hits the systemd imposed DefaultTasksMax limit of 19660 on my system.    A java heap dump shows that  4675 of the total 4877 match the expression Timer-.* and have the Context Class Loader-> org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$CleanGroovyClassLoader .    Bottom right corner of my Jenkins UI confirms I'm running the latest version (Jenkins ver. 2.176.2)with all plugins updated on OpenJDK Runtime Environment (build 1.8.0_222-b05) with. Ubuntu 18.04
          Kyle made changes -
          Attachment New: d119bce8-b89a-4ece-9327-a7fbfc791ff9.png [ 48052 ]

            dnusbaum Devin Nusbaum
            dnusbaum Devin Nusbaum
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: