2015年8月28日星期五

openfire 3.8.2 mysql high CPU 100%

I check the database statistics by(mysql > show full processlist;)

This query cosumed a lot CPU:

SELECT username FROM ofUser WHERE username LIKE ?


I read source code of openfire and found it has been used in following locations:

----------------------------------------
searching 'username like' in 'C:\openfire_src_3_8_2\openfire_src\src\java\org\jivesoftware\openfire\user\DefaultUserProvider.java' :
C:\openfire_src_3_8_2\openfire_src\src\java\org\jivesoftware\openfire\user\DefaultUserProvider.java(427):                 sql.append(" username LIKE ?");
found 'username like' 1 times。
----------------------------------------
searching  'username like' in 'C:\openfire_src_3_8_2\openfire_src\src\java\org\jivesoftware\openfire\user\JDBCUserProvider.java' :
C:\openfire_src_3_8_2\openfire_src\src\java\org\jivesoftware\openfire\user\JDBCUserProvider.java(326):                 sql.append(" username LIKE ?");
found  'username like' 1 times。


I changed like to =. 

SELECT username FROM ofUser WHERE username = ?

Then rebuild and replace openfire.jar of production.


Now mysql only cosume 4% CPU. :)



TAG: openfire 3.8.2 mysql high CPU 100%

没有评论:

发表评论