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

the EXECUTOR_NUMBER environment variable is not unique

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Fixed
    • ant-plugin
    • None
    • Platform: All, OS: Linux

    Description

      When two ant tasks are run in parallel, sometimes the EXECUTOR_NUMBER for the
      two tasks are the same. The EXECTOR_NUMBER variable should be unique for each
      task. Here is the documentation URL for the EXECUTOR_NUMBER environment variable.

      http://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project

      Below are the steps to reproduce this issue.

      Note: This defect seems to be non-deterministic. I will list the steps that,
      when followed, will often produce the described defect.

      1. Create four new Hudson jobs.
      2. Configure each job. Under each job's "Build" section Add a build step,
      select "invoke Ant".
      3. Click the "Advanced" button under the "Invoke Ant" section. Paste the
      following into the "Properties" text box.

      EXECUTOR_NUMBER=$EXECUTOR_NUMBER

      4. Configure the Ant build step of each job to run an ant task that prints out
      the ${EXECUTOR_NUMBER} variable.
      5. Setup Hudson to be able to run four executors simultaneously.
      6. Launch each of the four jobs in parallel. Try to launch them at the same
      time if possible.
      7. Look at the console output of each of the jobs. On some runs, two separate
      jobs will use the same executor number.
      8. When step 7 has finished, if the defect has not manifested itself, repeat
      steps 6 and 7.

      Attachments

        1. build.xml
          0.2 kB
        2. configuring_tasks.png
          configuring_tasks.png
          348 kB
        3. executor_list.png
          executor_list.png
          22 kB
        4. fix-HUDSON-4756+7357.patch
          5 kB
        5. task1.png
          task1.png
          519 kB
        6. task2.png
          task2.png
          500 kB
        7. task3.png
          task3.png
          551 kB
        8. task4.png
          task4.png
          492 kB

        Issue Links

          Activity

            TimoTM TimoTM added a comment -

            sounds similar

            TimoTM TimoTM added a comment - sounds similar
            mindless Alan Harder added a comment -

            See the linked duplicate issue for another possible way to reproduce the issue (adding+removing executors).

            mindless Alan Harder added a comment - See the linked duplicate issue for another possible way to reproduce the issue (adding+removing executors).

            I think the problem is that when an Executor is added to a Computer its number is set to Computer.executors.size(). This is not correct because when the number of executors was decreased for some reason (executor crash, decrease by config, ...) it is not always the last Executer that is removed from the Computer. If the number of executors is increased again (Thread restart, increase by config) the new executor should not just take Computer.executors.size() as its number but it should that a number in the range [0,numExecutors) that is not taken yet by another executor.

            I added a patch that fixes this issue.

            janickr janick reynders added a comment - I think the problem is that when an Executor is added to a Computer its number is set to Computer.executors.size(). This is not correct because when the number of executors was decreased for some reason (executor crash, decrease by config, ...) it is not always the last Executer that is removed from the Computer. If the number of executors is increased again (Thread restart, increase by config) the new executor should not just take Computer.executors.size() as its number but it should that a number in the range [0,numExecutors) that is not taken yet by another executor. I added a patch that fixes this issue.

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            core/src/main/java/hudson/model/Computer.java
            test/src/test/java/hudson/model/ExecutorTest.java
            http://jenkins-ci.org/commit/core/f88a2ba3336714a7d03b1d7b0f5a32b3c106cffd
            Log:
            Merge branch 'JENKINS-4756'

            • JENKINS-4756:
              minor touch up
              FIXED JENKINS-4756 the executor number was not always unique. Computer.executors.size() does not provide a unique number within one Computer.
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: core/src/main/java/hudson/model/Computer.java test/src/test/java/hudson/model/ExecutorTest.java http://jenkins-ci.org/commit/core/f88a2ba3336714a7d03b1d7b0f5a32b3c106cffd Log: Merge branch ' JENKINS-4756 ' JENKINS-4756 : minor touch up FIXED JENKINS-4756 the executor number was not always unique. Computer.executors.size() does not provide a unique number within one Computer.

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            changelog.html
            http://jenkins-ci.org/commit/core/85a8dd009a35377ca64d067d6cc4254e8ec29a16
            Log:
            [FIXED JENKINS-4756] recording the pull request #33 from Janick Reynders

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html http://jenkins-ci.org/commit/core/85a8dd009a35377ca64d067d6cc4254e8ec29a16 Log: [FIXED JENKINS-4756] recording the pull request #33 from Janick Reynders

            People

              Unassigned Unassigned
              mdemmitt mdemmitt
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: