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

Race-condition when checking out global library

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      It seems like PR:18 introduced a race-condition when you have several builds of the same job starting at the same time.
      Looking at the code in the pull request:

      try (WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(dir)) {
          delegate.checkout(run, dir, listener, node.createLauncher(listener));
          // Cannot add WorkspaceActionImpl to private CpsFlowExecution.flowStartNodeActions; do we care?
          // Copy sources with relevant files from the checkout:
          dir.copyRecursiveTo("src/**/*.groovy,vars/*.groovy,vars/*.txt,resources/", null, target);
      }
      

      We changed from using acquire to using allocate, which is non-blocking and instead append a suffix to the path if needed. The only problem with the change is that we still use the base directory given to allocate and ignoring the fact that we might have allocated another directory. Instead we should use lease.path, which is what we actually leased!

      So the code should probably be in the lines of:

      try (WorkspaceList.Lease lease = computer.getWorkspaceList().allocate(dir)) {
          delegate.checkout(run, lease.path, listener, node.createLauncher(listener));
          // Cannot add WorkspaceActionImpl to private CpsFlowExecution.flowStartNodeActions; do we care?
          // Copy sources with relevant files from the checkout:
          lease.path.copyRecursiveTo("src/**/*.groovy,vars/*.groovy,vars/*.txt,resources/", null, target);
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            jons Jon Sten added a comment -

            Introduced by change made for this issue

            Show
            jons Jon Sten added a comment - Introduced by change made for this issue

              People

              • Assignee:
                jons Jon Sten
                Reporter:
                jons Jon Sten
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: