• Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • maven-plugin
    • None
    • Platform: All, OS: All

      When we build a lot of projects, we have sometimes incorrect queue, a some
      projects could be builded to fast.
      Example:
      We have projects: x1, x2, x3, x4.
      Project x2 dependes on x1
      Project x3 dependes on x1
      Project x4 dependes on x2 and x3.
      When we start maven build of x1 project, later when the x2 project was builded,
      the x4 project is added to the queue and hudson start a build of the x4 project,
      but the x3 project now is builded.

      The hudson doesn't check downsreams in the actual, in the queue, in progress.

      We tried resolve those problems and we tested our changes.
      Changes aren't so much pretty, but ...

      Changes:
      1) class: MavenModuleSetBuild.RunnerImpl
      method: cleanUp(...){
      if (project.isAggregatorStyleBuild()) {
      // schedule downstream builds. for non aggregator style builds,
      // this is done by each module
      if (getResult().isBetterOrEqualTo(Result.SUCCESS)) {
      DependencyGraph graph = Hudson.getInstance().getDependencyGraph();
      Queue queue = Hudson.getInstance().getQueue();
      queue.executeWait();
      for (AbstractProject down : getProject().getDownstreamProjects()) {
      if (!graph.hasIndirectDependencies(getProject(), down)
      && !queue.hasIndirectDependenciesWithInProgress(getProject(), down))

      { listener.getLogger().println(Messages.MavenBuild_Triggering(down.getName())); down.scheduleBuild(); }

      }
      }
      }

      performAllBuildStep(listener, project.getPublishers(), false);
      performAllBuildStep(listener, project.getProperties(), false);
      }
      }

      2) class: Queue
      added method:
      @SuppressWarnings("unchecked")
      public synchronized boolean
      hasIndirectDependenciesWithInProgress(AbstractProject actualProject,
      AbstractProject dst) {
      Set<AbstractProject> visited = new HashSet<AbstractProject>();
      Stack<AbstractProject> queue = new Stack<AbstractProject>();

      for (ResourceActivity resourceActivity : inProgress)
      if (resourceActivity instanceof AbstractProject)
      queue.add((AbstractProject) resourceActivity);

      queue.remove(actualProject);

      while (!queue.isEmpty())

      { AbstractProject p = queue.pop(); if (p == dst) return true; if (visited.add(p)) queue.addAll(p.getDownstreamProjects()); }

      return false;
      }
      3) class: ResourceController
      add method:
      private boolean _wait = false;
      public synchronized void executeWait(){
      if(_wait)
      try

      { wait(); }

      catch (InterruptedException e) {
      }

      _wait = true;
      }

      4) class: ResourceController
      change in the method: execute(..)
      change from notifyAll() to notify()

          [JENKINS-2306] upstream build queue

          p_grzyb added a comment -

          I added changes to the version: 1.251

          p_grzyb added a comment - I added changes to the version: 1.251

          p_grzyb added a comment -

          This issue is very important, because we build a lot of projects and projects
          have a lot of dependencies from other building projects in a queue.

          p_grzyb added a comment - This issue is very important, because we build a lot of projects and projects have a lot of dependencies from other building projects in a queue.

          mdonohue added a comment -

          This issue was filed first, but issue 2736 covers the same thing, and has had a
          lot more activity.

              • This issue has been marked as a duplicate of 2736 ***

          mdonohue added a comment - This issue was filed first, but issue 2736 covers the same thing, and has had a lot more activity. This issue has been marked as a duplicate of 2736 ***

            Unassigned Unassigned
            p_grzyb p_grzyb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: