Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-50484

PortalImpl.getUniqueElementId() may end up in endless loop, because it isn't thread safe.

    Details

      Description

      Steps to reproduce

      1) Add a new page p1
      2) Add several Web Content Display portlets to p1
      3) Refresh p1 in the browser a couple of times

      Observe the CPU usage of the JVM either by JVisualVM or by using the following script.

      list_cpu_consumer_threads.sh
      #!/bin/sh
      
      pid=`jps -v | grep liferay | awk '{ print $1 }'`
      
      echo "JVM CPU usage:$(ps -o pcpu= -p $pid)%"
      
      nids=`pidstat -t -p $pid | sort -nr -k8 | head -6 | awk '{ print $4 }' | grep -v '^-' | xargs printf '0x%x\n'`
      
      for nid in $nids; do
        echo -e "\nDumping stack trace for native thread ${nid}"
        jstack -l $pid | grep -A 10 "nid\=${nid}" 
      done
      

      You should see that there are threads which got into an endless loop in method HashMap.getEntry().

      % bash /tmp/list_cpu_consumer_threads.sh
      JVM CPU usage: 279%
      
      Dumping stack trace for native thread 0x3c87
      "RuntimePageImpl-17" daemon prio=10 tid=0x00007fd120003800 nid=0x3c87 runnable [0x00007fd10f4f0000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.HashMap.getEntry(HashMap.java:469)
      	at java.util.HashMap.containsKey(HashMap.java:453)
      	at java.util.HashSet.contains(HashSet.java:201)
      	at com.liferay.portal.util.PortalImpl.getUniqueElementId(PortalImpl.java:5466)
      	at com.liferay.portal.util.PortalUtil.getUniqueElementId(PortalUtil.java:1873)
      	at com.liferay.taglib.ui.IconTag.getId(IconTag.java:366)
      	at com.liferay.taglib.ui.IconTag.setAttributes(IconTag.java:573)
      	at com.liferay.taglib.util.IncludeTag.callSetAttributes(IncludeTag.java:175)
      	at com.liferay.taglib.util.IncludeTag.doEndTag(IncludeTag.java:72)
      
      Dumping stack trace for native thread 0x3c82
      "RuntimePageImpl-13" daemon prio=10 tid=0x00007fd13001e000 nid=0x3c82 runnable [0x00007fd10f8f3000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.HashMap.getEntry(HashMap.java:469)
      	at java.util.HashMap.containsKey(HashMap.java:453)
      	at java.util.HashSet.contains(HashSet.java:201)
      	at com.liferay.portal.util.PortalImpl.getUniqueElementId(PortalImpl.java:5466)
      	at com.liferay.portal.util.PortalUtil.getUniqueElementId(PortalUtil.java:1873)
      	at com.liferay.taglib.ui.IconTag.getId(IconTag.java:366)
      	at com.liferay.taglib.ui.IconTag.setAttributes(IconTag.java:573)
      	at com.liferay.taglib.util.IncludeTag.callSetAttributes(IncludeTag.java:175)
      	at com.liferay.taglib.util.IncludeTag.doEndTag(IncludeTag.java:72)
      
      Dumping stack trace for native thread 0x3c88
      "RuntimePageImpl-18" daemon prio=10 tid=0x00007fd13c009800 nid=0x3c88 runnable [0x00007fd10f3ef000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.HashMap.getEntry(HashMap.java:469)
      	at java.util.HashMap.containsKey(HashMap.java:453)
      	at java.util.HashSet.contains(HashSet.java:201)
      	at com.liferay.portal.util.PortalImpl.getUniqueElementId(PortalImpl.java:5466)
      	at com.liferay.portal.util.PortalUtil.getUniqueElementId(PortalUtil.java:1873)
      	at com.liferay.taglib.ui.IconTag.getId(IconTag.java:366)
      	at com.liferay.taglib.ui.IconTag.setAttributes(IconTag.java:573)
      	at com.liferay.taglib.util.IncludeTag.callSetAttributes(IncludeTag.java:175)
      	at com.liferay.taglib.util.IncludeTag.doEndTag(IncludeTag.java:72)
      ...
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                joyce.wang Joyce Wang
                Reporter:
                laszlo.csontos Laszlo Csontos (Inactive)
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 26 weeks, 6 days ago