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

Two mutual exclusive builds are executed in parallel if they were added to the build queue at the same time.

      If two mutual exclusive builds sharing one lock are added to the build queue at the same time (e.g. 2 different tests jobs triggered after a successful build), both are "executed". One job runs as normal while the other hangs infinitely (console output is empty).

          [JENKINS-11031] Two mutual exclusive builds are executed in parallel if they were added to the build queue at the same time.

          Maybe the problem is related to the following observation:
          The locks-and-latches plugin seems to run AFTER the working area is updated with the latest code revision. Maybe both jobs are started in parallel (updating their working area) and the faster job wins the race for the lock (setting the lock now) while the other jobs gets stuck during his execution.

          Marcel Beister added a comment - Maybe the problem is related to the following observation: The locks-and-latches plugin seems to run AFTER the working area is updated with the latest code revision. Maybe both jobs are started in parallel (updating their working area) and the faster job wins the race for the lock (setting the lock now) while the other jobs gets stuck during his execution.

          Congratulations, you have observed the safety net.

          Locks and latches relies on Jenkins' own resource tracking for primary locking behaviour. There is an issue with the Jenkins' core functionality whereby two builds use the same resource can start at exactly the same time...

          Locks and Latches includes a safety net which uses real locks to ensure that one and only one job can build with the specified lock.

          Unfortunately the safety net can only kick in after SCM checkout.

          When the safety net kicks in one job will build and the other job will wait for the first job to finish.

          Verify that the second job waits for the first job to finish before continuing (unless you have the built timeout plugin timing out the second job that is). If the second job never finishes even after the first job has completed, then please reopen this issue with more details.

          Stephen Connolly added a comment - Congratulations, you have observed the safety net. Locks and latches relies on Jenkins' own resource tracking for primary locking behaviour. There is an issue with the Jenkins' core functionality whereby two builds use the same resource can start at exactly the same time... Locks and Latches includes a safety net which uses real locks to ensure that one and only one job can build with the specified lock. Unfortunately the safety net can only kick in after SCM checkout. When the safety net kicks in one job will build and the other job will wait for the first job to finish. Verify that the second job waits for the first job to finish before continuing (unless you have the built timeout plugin timing out the second job that is). If the second job never finishes even after the first job has completed, then please reopen this issue with more details.

            stephenconnolly Stephen Connolly
            simabeis Marcel Beister
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: