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

Pipeline jobs hangs after restart with build trigger step



      I finally reproduced the issue with pipeline stuck on our instance.

      how to reproduce it:

      1. create pipeline with build trigger step
      2. run pipeline
      3. kill/restart jenkins during execution of job which was triggered by the pipeline job (execution has to be started). The goal is to interrupt it without calling listener about stopping/failing execution (which usually can happen by restart or falling jenkins instance)
      4. after start of jenkins, there is pipeline job endlessly waiting for finishing the execution of triggered job and calling from listener about completion of the job execution.


      If I understand correctly the issue happens due this code:

      when execution of the step is called the resume value of execution thread is set on null


      the thread is not runnable until resume value is non null.


      until isRunnable returns true, thread group do not continue execution of this thread (and pipeline script) and expects that thread is waiting for completion of something (which in aforementioned case will never happen).



      In case of build step trigger, the listener should fire that everything is completed and set it in context which causes that resume value is no longer null and new run of thread group is scheduled.







      If I understand it correctly, currently everything is dependable on calling listener which does not have to be called by build in some unexpected situation or bug. It is not mistake in pipeline but I think that pipeline (or at least build trigger step) should count with such situation and handle it better. Because when the pipeline is in such state, this state is saved and no matter how many times the Jenkins is restarted it hangs forever until someone interrupt it form UI. 

      I thought about two solutions:

      build trigger solution - periodically check if job is still executing (no very nice solution)

      pipeline solution - extends api from something like - stillNotCompleted method, where it will periodically ask the build step if we are still waiting for some completion. 


      What do you think about it? Do you have any better idea how to solve it?



            Unassigned Unassigned
            lvotypkova Lucie Votypkova
            0 Vote for this issue
            3 Start watching this issue