Bug 51880

Summary: The shutdown command is not working if I invoke it before all the thread are started
Product: JMeter - Now in Github Reporter: Philippe Mouawad <p.mouawad>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: p.mouawad
Priority: P2    
Version: 2.5.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Fix to the issue
sample of shutdown problem with DummySample from jp@gc
Fix to startScheduler
Fix to startScheduler issue with last rev

Description Philippe Mouawad 2011-09-23 10:14:13 UTC
Hi,

If I try to stop a running test using "Shutdown", it never stops (even if
thread count is reduced till 0) and the windows stays open. I have to close
it and call stop to have the top left green box back to gray. Can someone
confirm this?
JMeter 2.5.1 r1174406, win xp sp3 32bits, jdk 1.6.

Regards,

Stef

One update:
The shutdown command is not working if I invoke it before all the thread are
started.
eg. If I start 20 thread and call it before the 20 are started, it fails. If
I call it once the 20 thread are started, it works.
The 'Stop' command works in both cases.

Regards,

Stef
Comment 1 Philippe Mouawad 2011-09-23 10:18:06 UTC
Created attachment 27575 [details]
Fix to the issue

Hello,
I reproduce your issue (not sure it's a new one).
In fact shutdown will succeed but only after initial rampup will have occured.

In current implementation, only stop was called without interruption of thread, so sleeping threads would be still blocked in sleep:
"Thread Group 1-23" prio=6 tid=101de3000 nid=0x125416000 waiting on condition [125415000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at org.apache.jmeter.threads.JMeterThread.rampUpDelay(JMeterThread.java:750)
	at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:491)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:245)
	at java.lang.Thread.run(Thread.java:680)


So my fix calls interrupt on Thread to give a chance to sleep to exit.
Regards
Philippe Mouawad
Comment 2 Sebb 2011-09-23 10:34:18 UTC
Thanks.

The patch may well work, but the point of Shutdown is to do so gracefully; i.e. allow threads to complete what they are doing. Generating an interrupt will cause problems for threads that have started.

I'll look into this further.
Comment 3 Sebb 2011-09-23 11:52:15 UTC
This was a side-effect of the fix for Bug 51839.

URL: http://svn.apache.org/viewvc?rev=1174675&view=rev
Log:
Bug 51880 - The shutdown command is not working if I invoke it before all the thread are started.

Modified:
   jakarta/jmeter/trunk/bin/jmeter.properties
   jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
   jakarta/jmeter/trunk/xdocs/changes.xml
Comment 4 stef 2011-09-27 04:36:53 UTC
Created attachment 27601 [details]
sample of shutdown problem with DummySample from jp@gc

Need to add JMeterPlugins.jar from http://code.google.com/p/jmeter-plugins/downloads/detail?name=JMeterPlugins-0.4.2.zip to lib/ext to open and run jmx.
Comment 5 Philippe Mouawad 2011-09-27 07:14:28 UTC
Hello,
I added JMeterPlugins.jar to lib/ext and tried to load your plan I got:
2011/09/27 09:12:32 ERROR - jmeter.save.SaveService: Conversion error com.thoughtworks.xstream.converters.ConversionException: kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
---- Debugging information ----
message             : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
path                : /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
line number         : 14
------------------------------- : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
---- Debugging information ----
message             : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
path                : /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
line number         : 14
-------------------------------
message             : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
---- Debugging information ----
message             : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
path                : /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
line number         : 14
-------------------------------
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup
first-jmeter-class  : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:69)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jorphan.collections.ListedHashTree
path                : /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
line number         : 14
------------------------------- 
2011/09/27 09:12:32 WARN  - jmeter.gui.action.Load: Unexpected error java.lang.Exception: Error in TestPlan - see log file
	at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:155)
	at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:110)
	at org.apache.jmeter.gui.action.Load.doAction(Load.java:89)
	at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:82)
	at org.apache.jmeter.gui.action.ActionRouter.access$0(ActionRouter.java:67)
	at org.apache.jmeter.gui.action.ActionRouter$1.run(ActionRouter.java:61)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:638)
	at java.awt.EventQueue$1.run(EventQueue.java:636)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Regards
Philippe Mouawad
Comment 6 Philippe Mouawad 2011-09-27 07:15:56 UTC
(In reply to comment #5)
> Hello,
> I added JMeterPlugins.jar to lib/ext and tried to load your plan I got:
> 2011/09/27 09:12:32 ERROR - jmeter.save.SaveService: Conversion error
> com.thoughtworks.xstream.converters.ConversionException:
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> ---- Debugging information ----
> message             : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> cause-exception     :
> com.thoughtworks.xstream.mapper.CannotResolveClassException
> cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> class               : org.apache.jorphan.collections.ListedHashTree
> required-type       : org.apache.jorphan.collections.ListedHashTree
> path                :
> /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
> line number         : 14
> ------------------------------- : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> ---- Debugging information ----
> message             : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> cause-exception     :
> com.thoughtworks.xstream.mapper.CannotResolveClassException
> cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> class               : org.apache.jorphan.collections.ListedHashTree
> required-type       : org.apache.jorphan.collections.ListedHashTree
> path                :
> /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
> line number         : 14
> -------------------------------
> message             : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> ---- Debugging information ----
> message             : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> cause-exception     :
> com.thoughtworks.xstream.mapper.CannotResolveClassException
> cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> class               : org.apache.jorphan.collections.ListedHashTree
> required-type       : org.apache.jorphan.collections.ListedHashTree
> path                :
> /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
> line number         : 14
> -------------------------------
> cause-exception     : com.thoughtworks.xstream.converters.ConversionException
> cause-message       : kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup :
> kg.apc.jmeter.threads.SteppingThreadGroup
> first-jmeter-class  :
> org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:69)
> class               : org.apache.jmeter.save.ScriptWrapper
> required-type       : org.apache.jorphan.collections.ListedHashTree
> path                :
> /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup
> line number         : 14
> ------------------------------- 
> 2011/09/27 09:12:32 WARN  - jmeter.gui.action.Load: Unexpected error
> java.lang.Exception: Error in TestPlan - see log file
>     at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:155)
>     at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:110)
>     at org.apache.jmeter.gui.action.Load.doAction(Load.java:89)
>     at
> org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:82)
>     at org.apache.jmeter.gui.action.ActionRouter.access$0(ActionRouter.java:67)
>     at org.apache.jmeter.gui.action.ActionRouter$1.run(ActionRouter.java:61)
>     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>     at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
>     at java.awt.EventQueue.access$000(EventQueue.java:85)
>     at java.awt.EventQueue$1.run(EventQueue.java:638)
>     at java.awt.EventQueue$1.run(EventQueue.java:636)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at
> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
>     at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
>     at
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
>     at
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
>     at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
>     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
>     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
>     at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
> 
> 
> Regards
> Philippe Mouawad

Forget about this, will take a cup of coffee to wakeup :-)
Comment 7 Philippe Mouawad 2011-09-27 07:32:52 UTC
Created attachment 27603 [details]
Fix to startScheduler

I reproduced bug.
Applied same fix method as Sebb did on rampUpDelay.

Thank you for your report.
If you have time to test patch would be nice.
Regards
Philippe Mouawad
Comment 8 Sebb 2011-09-27 09:00:20 UTC
(In reply to comment #7)
> Created attachment 27603 [details]
> Fix to startScheduler
> 
> I reproduced bug.

With which build of JMeter?

> Applied same fix method as Sebb did on rampUpDelay.

That fix has already been applied, and is in builds from r1174675 - see comment 3

> Thank you for your report.
> If you have time to test patch would be nice.

Please test against latest JMeter code - r1176077 is latest at present.
Comment 9 Philippe Mouawad 2011-09-27 09:08:11 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > Created attachment 27603 [details]
> > Fix to startScheduler
> > 
> > I reproduced bug.
> 
> With which build of JMeter?
> 
> > Applied same fix method as Sebb did on rampUpDelay.
> 
> That fix has already been applied, and is in builds from r1174675 - see comment
> 3
> 
> > Thank you for your report.
> > If you have time to test patch would be nice.
> 
> Please test against latest JMeter code - r1176077 is latest at present.

Hello Sebb,
I tested issue on last trunk revision.
No the fix has not been applied, you applied it on rampUpDelay method, here issue occurs on startScheduler, the patch I provided follows the fix you applied on rampUpDelay().

Regards
Philippe
Comment 10 Philippe Mouawad 2011-09-27 09:41:46 UTC
Created attachment 27607 [details]
Fix to startScheduler issue with last rev

Hello Sebb,
Ok I understood why you were saying I didn't test on last rev.

I retested before applying attached patch, Shutdown doesn't end until startime does, I get this thread dump :
2011-09-27 11:36:18
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.1-b02-384 mixed mode):

"jp@gc - Stepping Thread Group 1-2" prio=6 tid=101919800 nid=0x121701000 waiting on condition [121700000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at org.apache.jmeter.threads.JMeterThread.startScheduler(JMeterThread.java:213)
	at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:499)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:252)
	at java.lang.Thread.run(Thread.java:680)

"StandardJMeterEngine" prio=6 tid=103121000 nid=0x12011e000 in Object.wait() [12011d000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <7a18089d8> (a java.lang.Thread)
	at java.lang.Thread.join(Thread.java:1218)
	- locked <7a18089d8> (a java.lang.Thread)
	at org.apache.jmeter.engine.StandardJMeterEngine.waitThreadsStopped(StandardJMeterEngine.java:531)
	at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:434)
	at java.lang.Thread.run(Thread.java:680)



After patch it is OK.
Regards
Philippe
Comment 11 Sebb 2011-09-27 09:48:27 UTC
Sorry, I see now.

URL: http://svn.apache.org/viewvc?rev=1176299&view=rev
Log:
Bug 51880 - The shutdown command is not working if I invoke it before all the thread are started
Part2 - fix to startUp delay (previous fix was to rampUp delay)

Modified:
   jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java

Does that look OK now to you?
Comment 12 Philippe Mouawad 2011-09-27 09:51:33 UTC
Ok for me,
Stef is it Ok for you, you must get last hudson build on nightly build page (link at bottom)

Regards
Philippe
Comment 13 stef 2011-09-27 11:47:29 UTC
(In reply to comment #12)
> Ok for me,
> Stef is it Ok for you, you must get last hudson build on nightly build page
> (link at bottom)
> 
> Regards
> Philippe

Hi Philippe,

I tested it on r1176299, it works fine now. Thanks!

Stef
Comment 14 Philippe Mouawad 2011-09-27 11:52:37 UTC
Sebb, I close issue since stef said it was also OK for him.
Comment 15 The ASF infrastructure team 2022-09-24 20:37:47 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2560