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

Certain conditions might lock more resources than required quantity

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • CloudBees Jenkins Enterprise 2.32.2.1-rolling
      lockable resources plugin version 1.x & 2.x

      In strained situations, more resources than you asked for might get locked. This creates a bottleneck problem related to resources but it cannot be solved by adding more resources.

      In worst cases will always lock all resources with a certain label instead of the required amount.

      You can recreate the issue by configuring a couple (say 4) of lockable resources with a tag. Trigger a bunch of these jobs with NUM_RESOURCES between 1 - 4 to build up a queue of jobs waiting for their resources to become available. Eventually the error will start appearing.

      properties([
          parameters ([
              string(name: 'NUM_RESOURCES')
          ])
      ]);
      
      node {
          def askFor = params.NUM_RESOURCES as Integer
          lock(label: "FOO", quantity: askFor) {
              def clients = org.jenkins.plugins.lockableresources.LockableResourcesManager.class.get().getResourcesFromBuild(currentBuild.getRawBuild())
              echo("Asked for ${askFor} resources, got ${clients.size()}: ${clients.toString()}")
              sleep (60 * 10)
              if (askFor != clients.size()) {
                  error ("Wrong amount of resources acquired")
              }
          }
      }
      

          [JENKINS-46494] Certain conditions might lock more resources than required quantity

          Marcus Antonsson created issue -
          Marcus Antonsson made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Marcus Antonsson made changes -
          Status Original: In Progress [ 3 ] New: Open [ 1 ]
          Marcus Antonsson made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Marcus Antonsson made changes -
          Remote Link New: This issue links to "Pull request (Web Link)" [ 17531 ]
          Marcus Antonsson made changes -
          Status Original: In Progress [ 3 ] New: Open [ 1 ]
          Marcus Antonsson made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Marcus Antonsson made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Marcus Antonsson made changes -
          Status Original: In Review [ 10005 ] New: In Progress [ 3 ]

          Jens Beyer added a comment -

          Seeing this issue massively.

          We have 9 labelled resources.

          Build 1 reserves 4.

          Build 2 reserves 4.

          Build 3 wants to reserve 4, and waits.

          Build 1 finishes and unlocks.

          Now the bug: Build 3 locks 5, although in log it says it locks 4.

           

          I'll happily play beta tester for a .hpi, this is bugging us quite much (we also often see builds reserve 4 to 5 when they only request 1, and this is really blocking) 

           

          Jens Beyer added a comment - Seeing this issue massively. We have 9 labelled resources. Build 1 reserves 4. Build 2 reserves 4. Build 3 wants to reserve 4, and waits. Build 1 finishes and unlocks. Now the bug: Build 3 locks 5, although in log it says it locks 4.   I'll happily play beta tester for a .hpi, this is bugging us quite much (we also often see builds reserve 4 to 5 when they only request 1, and this is really blocking)   

            Unassigned Unassigned
            mantonsson Marcus Antonsson
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: