Bug 58209 - Jmeter hang when testing javasampler because HashMap.put() is called from multiple threads without sync.
Summary: Jmeter hang when testing javasampler because HashMap.put() is called from mul...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.12
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-05 07:11 UTC by Ejay
Modified: 2015-08-08 16:57 UTC (History)
1 user (show)



Attachments
jstack info (7.89 KB, text/plain)
2015-08-05 07:11 UTC, Ejay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ejay 2015-08-05 07:11:23 UTC
Created attachment 32959 [details]
jstack info

Jmeter hang when testing javasampler with num_threads>6000 , because HashMap.put() from multiple threads.

As the following,knowing the thread hang at HashMap.put();
look into the process's jstack info(full content attached):


2015-08-05 14:48:48
Full thread dump OpenJDK (Taobao) 64-Bit Server VM (20.0-b12-internal mixed mode):

"Attach Listener" daemon prio=10 tid=0x00007f078fd5a000 nid=0x4204 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"线??组 1-2788" prio=10 tid=0x00007f07e0111000 nid=0x5fad runnable [0x00007f079d99d000]
   java.lang.Thread.State: RUNNABLE
    at java.util.HashMap.put(HashMap.java:374)
    at java.util.HashSet.add(HashSet.java:200)
    at org.apache.jmeter.protocol.java.sampler.JavaSampler.createJavaClient(JavaSampler.java:227)
    at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(JavaSampler.java:190)
    at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:431)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:258)
    at java.lang.Thread.run(Thread.java:662)

"pool-1-thread-1" prio=10 tid=0x00007f0848a90800 nid=0x5c43 waiting on condition [0x00007f07ebca4000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at io.netty.util.HashedWheelTimer$Worker.waitForNextTick(HashedWheelTimer.java:461)
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:360)
    at java.lang.Thread.run(Thread.java:662)

"线程组 1-1847" prio=10 tid=0x00007f083c96b800 nid=0x5b54 runnable [0x00007f07f9178000
...
Comment 1 Ejay 2015-08-05 07:25:18 UTC
Invoking HashMap.put() from multiple threads casue jmeter hanging

I think the solution is:
change java file :src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java    at line 60 

   //private static final Set<JavaSampler> TEAR_DOWN_SET = new HashSet<JavaSampler>();
    private static final Set<JavaSampler> TEAR_DOWN_SET =  Collections.newSetFromMap(new ConcurrentHashMap<JavaSampler,Boolean>());
Comment 2 Sebb 2015-08-08 16:57:51 UTC
Thanks very much for the report.
The fix has been applied and will be in the next release of JMeter

URL: http://svn.apache.org/r1694819
Log:
JMeter hang when testing javasampler because HashMap.put() is called from multiple threads without sync.
Bugzilla Id: 58209

Modified:
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
    jmeter/trunk/xdocs/changes.xml