• Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Blocker Blocker
    • workflow-cps-plugin
    • None

      Aborting job that has multiple parallel threads keeps one or more threads lingering, while consuming the executor.

      I do not see any way of killing those threads and aborting the build.

      Here is the thread dump:

      Thread #94
      at DSL.dir(Native Method)
      at WorkflowScript.run(WorkflowScript:246)
      at DSL.node(Native Method)
      at WorkflowScript.run(WorkflowScript:222)

          [JENKINS-35663] Aborting pipeline build does not work

          Jesse Glick added a comment -

          Any known way to reproduce from scratch? What software versions?

          Jesse Glick added a comment - Any known way to reproduce from scratch? What software versions?

          Nenad Miksa added a comment -

          Our pipeline which causes this behaviour is attached buildCore.groovy common.groovy - you can modify them for your needs to reproduce the issue.

          Nenad Miksa added a comment - Our pipeline which causes this behaviour is attached buildCore.groovy common.groovy - you can modify them for your needs to reproduce the issue.

          Jesse Glick added a comment -

          Would need a minimal, self-contained reproducible test case.

          Jesse Glick added a comment - Would need a minimal, self-contained reproducible test case.

          kyle calica added a comment -

          I'm actually having a similar problem. I have a plugin I am developing that creates a bunch of parallel threads. I abort the build but my threads continue to run.

          In my own code I have done this crazy catch all thing to try and kill them. Doesn't work. I so far have to wait for them to finish out no matter what.

          catch(InterruptedException e) {

          listener.getLogger().println("Stopping all scenarios due to: " + e.toString());
          executor.shutdownNow(); //halts all tasks

          //tries to shutdown all threads again
          try {
          // Wait a while for existing tasks to terminate
          if (!executor.awaitTermination(60, TimeUnit.SECONDS))

          Unknown macro: { executor.shutdownNow(); // Cancel currently executing tasks // Wait a while for tasks to respond to being cancelled if (!executor.awaitTermination(60, TimeUnit.SECONDS)) System.err.println("Thread pool did not terminate"); }

          } catch (InterruptedException ie)

          Unknown macro: { // (Re-)Cancel if current thread also interrupted executor.shutdownNow(); // Preserve interrupt status Thread.currentThread().interrupt(); }

          //cancel each future in case it couldn't cancel threads
          try{
          for(Future<Scenario> r : futures)

          Unknown macro: { listener.getLogger().println( "Cancelling}

          }catch(ExecutionException ex)

          Unknown macro: { ex.printStackTrace(); listener.getLogger().println("Not able to cancel threads."); }

          e.printStackTrace();

          throw e;

          kyle calica added a comment - I'm actually having a similar problem. I have a plugin I am developing that creates a bunch of parallel threads. I abort the build but my threads continue to run. In my own code I have done this crazy catch all thing to try and kill them. Doesn't work. I so far have to wait for them to finish out no matter what. catch(InterruptedException e) { listener.getLogger().println("Stopping all scenarios due to: " + e.toString()); executor.shutdownNow(); //halts all tasks //tries to shutdown all threads again try { // Wait a while for existing tasks to terminate if (!executor.awaitTermination(60, TimeUnit.SECONDS)) Unknown macro: { executor.shutdownNow(); // Cancel currently executing tasks // Wait a while for tasks to respond to being cancelled if (!executor.awaitTermination(60, TimeUnit.SECONDS)) System.err.println("Thread pool did not terminate"); } } catch (InterruptedException ie) Unknown macro: { // (Re-)Cancel if current thread also interrupted executor.shutdownNow(); // Preserve interrupt status Thread.currentThread().interrupt(); } //cancel each future in case it couldn't cancel threads try{ for(Future<Scenario> r : futures) Unknown macro: { listener.getLogger().println( "Cancelling} }catch(ExecutionException ex) Unknown macro: { ex.printStackTrace(); listener.getLogger().println("Not able to cancel threads."); } e.printStackTrace(); throw e;

          Jesse Glick added a comment -

          I abort the build but my threads continue to run.

          StepExecution.stop though this would be a dev list question generally.

          Jesse Glick added a comment - I abort the build but my threads continue to run. StepExecution.stop though this would be a dev list question generally.

            Unassigned Unassigned
            dodoent Nenad Miksa
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: