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

Locks within parallel tasks release other locks within the pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When a pipeline has an outer lock of a resource and then runs multiple tasks in parallel which have inner locks. The outer lock is sometimes prematurely cleared when the parallel tasks clear their inner lock.

      This bug was introduced in 1.11 and does not appear in 1.10

      A sample pipeline job is below. When the 1st parallel jobs completes, it releases the inner lock as expected. When the 2nd parallel job completes, it releases the inner lock but the outer lock is also cleared. This could be due to clean up code that is clearing a resource lock that it shouldn't be.

      node('master'){
        // outer lock here, this should persist until the end
        lock('outer') {
          sh "sleep 10"
          def stepsForParallel = [:]
          for (int i = 1; i <= 4; i++) {
            def stepName = "Inner Run - ${i}"
            stepsForParallel[stepName] = test()   
          }
          parallel stepsForParallel
          sh "sleep 10"
        }
      }
      
      def test() {
        return {
          // create an inner lock which the parallel tasks will queue around
          lock('inner') {
            sh "sleep 10"
          }
        }
      }
      

        Attachments

          Issue Links

            Activity

            marknysen Mark Nysen created issue -
            marknysen Mark Nysen made changes -
            Field Original Value New Value
            Summary Locks within parallel tasks release other locks within a project Locks within parallel tasks release other locks within the pipeline
            Hide
            marknysen Mark Nysen added a comment -

            This may be the same issue seen in JENKINS-41183

            Show
            marknysen Mark Nysen added a comment - This may be the same issue seen in JENKINS-41183
            abayer Andrew Bayer made changes -
            Link This issue duplicates JENKINS-40879 [ JENKINS-40879 ]
            abayer Andrew Bayer made changes -
            Resolution Duplicate [ 3 ]
            Status Open [ 1 ] Resolved [ 5 ]

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              marknysen Mark Nysen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: