 |
 |
 |
 |
Registered: 01/04/09
Posts: 1
|
|
|
 |
 |
 |
 |
|
 |
 |
 |
 |
#217274 - 09/24/08 12:26 PM
simple sql query causing 100% cpu usage for minutes
|
stranger
Registered: 09/18/08
Posts: 14
Loc: Utah
|
I realize that this is somewhat of a mysql question, but here it goes:
Our whole board is basically frozen at random times because (it seems like it anyway) of this simple ubb query:
select COUNT(t1.POST_ID) as posts, sum(t1.POST_IS_TOPIC) as topics from ubbt_POSTS as t1
Here's the history: Everything's running fine. Suddenly, the board seems frozen and everyone is getting http timeouts. So, I log in and find that mysqld (5.0.22) is at roughly 100% CPU usage. I look at the processlist and the above query is the only thing running in the processlist except my "show processlist" query. The PID does change, but only after 15-20 seconds or so. If I run the query on its own, it takes 1.41 to 1.46 seconds every time under normal circumstances.
Restarting mysqld clears the problem, and everything is running as expected... for a while. Then the problem returns. It does seem to clear itself after 15-20 minutes, but I think that's just because everyone gives up trying to access anything.
I thought it was twiceler, but it wasn't as it's blocked now.
I tried running optimize table on ubbt_POSTS, but that didn't fix it.
There are no cron jobs, and this is 5.0.22, so there are no scheduled tasks from within the db itself.
What am I missing?
|
|
Top
|
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#217312 - 09/25/08 11:42 AM
Re: simple sql query causing 100% cpu usage for minutes
[Re: Rick]
|
stranger
Registered: 09/18/08
Posts: 14
Loc: Utah
|
Yup - still having problems. I turned the option off (CP -> Display options -> Primary -> Forum Display options -> Show total # of unread replies in topics? ) and yet was still having the site basically unaccessible 6-7 hours later. It was obvious that the option was unchecked because the unread posts were not listed as they were before.
I'm REALLY ashamed to admit to this hack, but here's where we are now: I'm headed out for the weekend and won't be able to babysit until Sunday night. So, I've got mysqld restarting every half-hour. Things are better now, but users still reported some slowness last night.
I rebooted the server, but that didn't have any effect.
I really can't tell you that that query is definitely the cause of the problem, but I can say that it was running during the slowdowns. However, that could just be that that was the slowest of the processes and the only one I was able to "catch" by running "show processlist;".
As a side note, the number of locks (table_locks_immediate) sky rockets during our periods of slowness. Right now (period of moderate to high activity for us) I saw a peak right around 25k locks, but that number dropped to 1100 shortly after the automatic restart and has been climbing since. That number shoots up to around (well, just under) 1 million when the system's hammered. I have no idea if that's relevant, but
Right this moment, we have literally 2-3 times the number of users showing up in "who's online" than we had last night during a slowdown, so I don't think the server's getting overloaded by any means.
Thanks for the info about connections. I'm not reading things wrong then...
Frankly, I'm baffled. We did just to a major upgrade/migration back in June to ubb7. However, we hadn't seen problems until last week, so I don't know if that's relevant either.
|
|
Top
|
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#217437 - 09/29/08 11:26 PM
Re: simple sql query causing 100% cpu usage for minutes
[Re: Rick]
|
stranger
Registered: 09/18/08
Posts: 14
Loc: Utah
|
Dumb question; are you by chance using persistant connections in your ubb config to connect to the mysql db? If so, I'd highly advise turning them off... Nope. I just checked. We're not. Thanks for the heads up though. Just took a peek at your forum, even registered so I could get a good look at the size of your forum. Thanks. I love this internet thing. I'm betting it might just catch on one day... It's not all that large, so even having the total # of unread topics/posts turned on should be that bad at all. I was thinking maybe the search could be doing it as sometimes it can lock while doing a large search over all posts, however on the size of your forum, that shouldn't be an issue either. Yeah, and that's the thing. I'm pretty new to all of this (baptism by fire I suppose), but I've used ubb in LOTS of other settings and it's never been an issue with much bigger sites. I've just never known what they've had running on the back end. I deal with pretty big iron for my day job, so a 2x2.8GHz P4 w/ 1.5GB RAM config seems awfully slow to me at first glance. Are you logging slow queries in your mysql configuration? I'm going to have to get back to you on that one. Now, with all that said, I'm not sure we'll ever know exactly what was the problem. The guy at our ISP ran a bunch of OS updates - including moving us to mysql 5.0.45 and running myisamchk (which was probably the same as optimize table). So far so good. It very well may have been completely unrelated to ubb.
|
|
Top
|
|
|
|
|
 |
 |
 |
 |
|
|