Bug 64499

Summary: Exiting JMeter when "jmeterengine.stopfail.system.exit=true" takes too much time if threads are not stopped
Product: JMeter Reporter: Philippe Mouawad <p.mouawad>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: p.mouawad
Priority: P2 Keywords: FixedInTrunk
Version: 5.0   
Target Milestone: JMETER_5.4   
Hardware: All   
OS: All   

Description Philippe Mouawad 2020-06-05 16:08:34 UTC
The setting "jmeterengine.stopfail.system.exit=true"  is intended to make JMeter exit when some threads are still not stopped or hanged.

But currently this is what happens when test is stopped (now == true):
The StopTest thread if asked to stop now:
https://github.com/apache/jmeter/blob/master/src/core/src/main/java/org/apache/jmeter/engine/StandardJMeterEngine.java#L322

1) Asks threads of threads groups to stop
2) Pauses for 10ms * Number of threads (may be improvable by capping it to a max of 30s), not the main problem
3) verifyThreadsStopped : 
a) The problem is here, the method continues to loop even if one threadGroup.verifyThreadsStopped() returns false => Not optimal, I would suggest to exit on first false
b) ThreadGroup#verifyThreadsStopped has the same problem but worst it waits 5s per thread to join

So by default , if we have 100 threads still hanged , we end up waiting 
- Number of thread hanged * 10ms + Number of thread hanged * 5000 ms 


While if we exit on first false, we would wait :
- Number of thread hanged * 10ms + 5000 ms
Comment 1 Philippe Mouawad 2020-06-06 20:01:06 UTC
pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 0318c50  Bug 64499 - Exiting JMeter when "jmeterengine.stopfail.system.exit=true" takes too much time if threads are not stopped
0318c50 is described below

commit 0318c50a8a55d5be533a9150885e2facf04358a7
Author: pmouawad <p.mouawad@ubik-ingenierie.com>
AuthorDate: Sat Jun 6 21:57:52 2020 +0200

    Bug 64499 - Exiting JMeter when "jmeterengine.stopfail.system.exit=true"
    takes too much time if threads are not stopped
---
 .../java/org/apache/jmeter/engine/StandardJMeterEngine.java  |  7 ++++---
 .../src/main/java/org/apache/jmeter/threads/ThreadGroup.java | 12 +++++++++---
 xdocs/changes.xml                                            |  1 +
 3 files changed, 14 insertions(+), 6 deletions(-)