Locking a resource while holding it locked in the same job is not possible

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Locking a resource while holding it locked in the same job like this:

      lock(resource: 'res1'){
        sleep(time: 2, unit: 'SECONDS')
        lock(resource: 'res1'){
          sleep(time: 2, unit: 'SECONDS')
        }
      }
      

      results in indefinite wait:

      Trying to acquire lock on [res1]
      Resource [res1] did not exist. Created.
      Lock acquired on [res1]
      [Pipeline] {
      [Pipeline] sleep
      Sleeping for 2 sec
      [Pipeline] lock
      Trying to acquire lock on [res1]
      Found 0 available resource(s). Waiting for correct amount: 1.
      [res1] is locked by job-name #NN waiting...

      I would expect the inner lock to be granted immediately since the job has already acquired exclusive access to the resource.

            Assignee:
            Unassigned
            Reporter:
            Eugene Pliskin
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: