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

NPE from CpsStepContext.scheduleNextRun

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Fixed
    • workflow-cps-plugin
    • None
    • Jenkins 2.53
      workflow-cps 2.29

    Description

      After a timeout occurence, my pipeline wil leventually end with a message

      Body did not finish within grace period; terminating with extreme prejudice"
      

       Later on, build failure analyzer and lockable-resources do their work (analyzing and unlicking), github-branch-source signals the run result to github and and exception is printed:

      java.lang.NullPointerException
      	at org.jenkinsci.plugins.workflow.cps.CpsStepContext.scheduleNextRun(CpsStepContext.java:386)
      	at org.jenkinsci.plugins.workflow.cps.CpsStepContext.completed(CpsStepContext.java:339)
      	at org.jenkinsci.plugins.workflow.cps.CpsStepContext.onFailure(CpsStepContext.java:328)
      	at org.jenkinsci.plugins.workflow.cps.CpsBodySubContext.onFailure(CpsBodySubContext.java:63)
      	at org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback$TailCall.onFailure(BodyExecutionCallback.java:128)
      	at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$FailureAdapter.receive(CpsBodyExecution.java:345)
      	at com.cloudbees.groovy.cps.impl.ThrowBlock$1.receive(ThrowBlock.java:68)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:74)
      ...
      Finished: FAILURE
      

      The run will stop showing at the build queue (is not using a lightweight nor a normal executor), but after a Jenkins restart, it will appear again, queued waiting for an agent:

      Resuming build at Wed Apr 05 09:34:49 CEST 2017 after Jenkins restart
      Waiting to resume part of Crossdata » crossdata-spark2 » PR-5 #2: ???
      Waiting to resume part of Crossdata » crossdata-spark2 » PR-5 #2: There are no nodes with the label ...
      

      This might show that a CPSThread isnt completelly killed, and seems to be related to myself capturing the timeout exception, handling it and rethrowing. With the NPE, the execution flow hungs forever, leading to resources extarvation.

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            No. Anyway the fix is only symptomatic and it is quite possible something else will be gravely broken after updating.

            jglick Jesse Glick added a comment - No. Anyway the fix is only symptomatic and it is quite possible something else will be gravely broken after updating.

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/c61336f0168335673d9aac2a53a691e093e7bd6e
            Log:
            Merge pull request #119 from jglick/NPE-JENKINS-43361

            JENKINS-43361 Unreproducible NPE

            Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/92019ea28877...c61336f01683

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java http://jenkins-ci.org/commit/workflow-cps-plugin/c61336f0168335673d9aac2a53a691e093e7bd6e Log: Merge pull request #119 from jglick/NPE- JENKINS-43361 JENKINS-43361 Unreproducible NPE Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/92019ea28877...c61336f01683

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java
            src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/425be8515cfaabd19de5db6a10c3f82875fd72f9
            Log:
            JENKINS-43361 Unreproducible NPE.

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java src/main/java/org/jenkinsci/plugins/workflow/cps/CpsStepContext.java http://jenkins-ci.org/commit/workflow-cps-plugin/425be8515cfaabd19de5db6a10c3f82875fd72f9 Log: JENKINS-43361 Unreproducible NPE.
            gregcovertsmith Greg Smith added a comment -

            I'm not sure how to recreate, but we are getting this too. 

            The builds effected by this end up zombies, and don't seem to want to be killed.

            Is there a best-practice workaround to this problem until the fix is available? 

            gregcovertsmith Greg Smith added a comment - I'm not sure how to recreate, but we are getting this too.  The builds effected by this end up zombies, and don't seem to want to be killed. Is there a best-practice workaround to this problem until the fix is available? 
            jglick Jesse Glick added a comment -

            Faulty line:

            parents.add(flow.getFlowHead(head).get());
            

            Presumably getFlowHead is returning null.

            Any known way to reproduce from scratch?

            jglick Jesse Glick added a comment - Faulty line : parents.add(flow.getFlowHead(head).get()); Presumably getFlowHead is returning null. Any known way to reproduce from scratch?

            People

              jglick Jesse Glick
              witokondoria Javier Delgado
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: