[ https://issues.apache.org/jira/browse/KYLIN-2716?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Zhong Yanghong updated KYLIN-2716: ---------------------------------- Summary: Using non-thread-safe WeakHashMap leading to server high cpu (was: WeakHashMap in ClassUtil leading to server high cpu and some query doesn't respond) > Using non-thread-safe WeakHashMap leading to server high cpu > ------------------------------------------------------------ > > Key: KYLIN-2716 > URL: https://issues.apache.org/jira/browse/KYLIN-2716 > Project: Kylin > Issue Type: Bug > Components: Query Engine > Affects Versions: all > Reporter: Zhong Yanghong > Assignee: Zhong Yanghong > > WeakHashMap is not thread safe, which is used in the method > *ClassUtil.forName*. It's a high possibility that multiple threads invoke the > method *ClassUtil.forName* simultaneously leading to a dead loop in > *WeakHashMap.get() -> getTable() -> expungeStaleEntries()*, which finally > resulting in server high cpu and some query doesn't respond. > We made an inner test by invoking the method *ClassUtil.forName* 1M times, > the result is as follows: > * With cache: 20ms; > * Without cache: less than 2s. > By invoking the method *ClassUtil.forName* with *newInstance* 1M times, the > result is as follows: > * With cache: around 2s > * Without cache: around 3s. > Considering *ClassUtil.forName* is always invoked with *newInstance*, there's > no much downgrade without cache. Thus the fix is just to remove the cache. -- This message was sent by Atlassian JIRA (v6.4.14#64029)