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

stage concurrency allows 1 thread to be blocked at a time, others fail and hang job

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • pipeline
    • None
    • Jenkins 1.606
      Workflow 1.5

      Take the following script as an example:

      node {
          def sleeps = [ : ]
          for (int i = 0; i < 4; i++) {
              sleeps["num_${i}"] = { sleep60() }
          }
          parallel(sleeps)
      }
      
      def sleep60 () {
          ws {
              stage name: "Sleep for 60 secs", concurrency: 1
              sh "sleep 60"
          }
      }
      

      Because the stages are marked with concurrency: 1, I would expect the sleeps to occur in series, but with all "parallel" tasks performed. With 3, then 2, then 1 task blocked until all are complete.

      Instead the first sleep runs, the second blocks on it, but the other two mysteriously "fail", and this actually results in the Job hanging indefinitely and the 2nd sleep doesn't seem to get to run either.

      Started by user anonymous
      Running: Allocate node : Start
      Running on master in /mydir/jenkins/workspace/Sandbox
      Running: Allocate node : Body : Start
      Running: Execute sub-workflows in parallel : Start
      [num_0] Running: Parallel branch: num_0
      [num_1] Running: Parallel branch: num_1
      [num_2] Running: Parallel branch: num_2
      [num_3] Running: Parallel branch: num_3
      [num_0] Running: Allocate workspace : Start
      [num_0] Running in /mydir/jenkins/workspace/Sandbox-2
      [num_0] Running: Allocate workspace : Body : Start
      [num_1] Running: Allocate workspace : Start
      [num_1] Running in /mydir/jenkins/workspace/Sandbox-3
      [num_1] Running: Allocate workspace : Body : Start
      [num_2] Running: Allocate workspace : Start
      [num_2] Running in /mydir/jenkins/workspace/Sandbox-4
      [num_2] Running: Allocate workspace : Body : Start
      [num_3] Running: Allocate workspace : Start
      [num_3] Running in /mydir/jenkins/workspace/Sandbox-5
      [num_3] Running: Allocate workspace : Body : Start
      [num_0] Running: Sleep for 60 secs
      [num_0] Entering stage Sleep for 60 secs
      [num_0] Proceeding
      [num_0] Running: Shell Script
      [num_0] [Sandbox-2] Running shell script
      [num_1] Running: Sleep for 60 secs
      [num_1] Entering stage Sleep for 60 secs
      [num_1] Waiting for builds [7]
      [num_2] Running: Sleep for 60 secs
      [num_2] Entering stage Sleep for 60 secs
      Running: Allocate workspace : Body : End
      [num_3] Running: Sleep for 60 secs
      [num_3] Entering stage Sleep for 60 secs
      Running: Allocate workspace : Body : End
      Running: Allocate workspace : End
      Running: Allocate workspace : End
      Running: Execute sub-workflows in parallel : Body : End
      Running: Execute sub-workflows in parallel : Body : End
      [num_0] + sleep 60
      Running: Allocate workspace : Body : End
      Running: Allocate workspace : End
      Running: Execute sub-workflows in parallel : Body : End
      

      I assume this is just a bug rather than my misunderstanding of the use of concurrency but I'm happy to be corrected!

            jglick Jesse Glick
            tomjdalton Thomas Dalton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: