0

Have written a java process in spring-boot, process uses fork-join pool.

Process run fine sometimes and completed successfully, sometimes it hangs indefinitely start using very high cpu still making no progress on task.

Thread dump show runnable state for only 3 types of work which are as follows:

 1.  java.lang.Thread.State: RUNNABLE
    at java.util.WeakHashMap.put(WeakHashMap.java:453)
    at java.util.Collections$SetFromMap.add(Collections.java:5461)
    at org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl.initTargetClientIfNeeded(ClientImpl.java:358)
    at org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl.request(ClientImpl.java:260)
    at org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl.request(ClientImpl.java:366)

2. "C2 CompilerThread2" #30 daemon prio=9 os_prio=0 tid=0x00007ff9b0979000 nid=0x250be waiting on condition [0x0000000000000000]
           java.lang.Thread.State: RUNNABLE

3."GC task thread#12 (ParallelGC)" os_prio=0 tid=0x00007ff9b0034800 nid=0x24f94 runnable          

Further trying to debug issue, I have few inputs ::

I am using org.apache.cxf.jaxrs.client, When analysed found initTargetClientIfNeeded method of ClientImpl is using 2 property thread.safe.client and thread.safe.client.state.cleanup.period. Do i need to define these 2 properties to make it thread safe ?

laughing buddha
  • 351
  • 3
  • 10
  • I'm pretty sure, you're using the map without synchronization. `WeakHashMap` works AFAIK just like `HashMap` in this respect. Read the answers there and let me / the community know if your case differs - edit the question to point out the differences. – maaartinus Oct 05 '18 at 20:18
  • I am using org.apache.cxf.jaxrs.client, When analysed found initTargetClientIfNeeded method of ClientImpl is using 2 property thread.safe.client and thread.safe.client.state.cleanup.period. Do i need to define these 2 properties to make it thread safe ? – laughing buddha Oct 07 '18 at 09:38
  • @maaartinus I have posted bigger stacktrace, where it shows the work-flow once it enter cxf client – laughing buddha Oct 07 '18 at 09:48
  • @maaartinus Please remove duplicate label from the question, My concern is not with hash map leading to infinite loop, but it is towards solving this situation. – laughing buddha Oct 08 '18 at 00:23
  • OK, I reopened the question as it's probably sufficiently different now. I'd for sure try to set all `thread.safe.*` properties and look if it helps. I'd also start a debugger, let the code enter the infinite loop and then set a breakpoint on `WeakHashMap.java:453`. – maaartinus Oct 08 '18 at 22:59
  • @maaartinus Thanks for help. Actually issue is intermittent and hard to reproduce on local. I have till now seen issue only on production. I will try to reproduce it on local and debug it. – laughing buddha Oct 09 '18 at 04:47

0 Answers0