Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have strange problem with this setup. Strangely it occurs only when using owncloud from one specific computer.

Problem is when user click on "Activities" an "document" icons one after another sometimes postgresql starts to use insane amount of cpu and site stops working (504) but only for this one specific client, other computers still can use the site. First thing what helps is restarting nginx.

But after I learn how to reproduce this error and noticed that postgresql is using 100% of one of cpu cores. I figured out that restarting only postgresql helps too. So it must be postgres related error. But I got no trace of cause in any log files I checked

  • nginx-(nginx/error.log) log connection timed out to upstream (php5-fpm I assume)
  • php5-fpm log(log/php5-fpm.log ) is clear - no entries besides starting a service
  • postgresql logs(postgresql-9.1-main.log) - the same

I tried update the browser on the client with no effect. Can you point where else should I look for the cause? Maybe I can set it up to kill/restart the database connection that is causing the problem? I'm really out of ideas

Tried reproduce this on other computers with same Firefox and Windows 7 versions(same updates) with no success.

How can I check what postgresql is trying to do when it's working so hard and endlessly?

Configs are pretty much all defaults besides increasing pm.max_children for php5-fpm and add a pm.max_requests = 5000 to it - that was before I notice database behaviour. Nginxn config is straight from ownCloud docs. Server is running Ubuntu 12.04

share|improve this question
1  
Check pg_stat_activity (a system view) for the process ID of the PostgreSQL backend that's running at 100% cpu to see what it's doing and what connection is using it. –  Craig Ringer Apr 18 at 10:15
    
I reproduced error and did SELECT * FROM pg_stat_activity; and it shows one connection besides the one I'm making query on, but no useful info. It shows database name and user but I already know that. Only curious thing is `current_query_text <IDLE>' - if it is idle why it eats all resources? How to extract/dig deeper for any useful info? –  Lord_JABA Apr 18 at 14:57
    
But does that entry have the pid of the one that is using all the cpu? Get the pid of the proc using cpu from top. Check if there is a pg_stat_activity entry for it. If not check pstree (with pids shown, see man pstree) and also do a ps aux | grep the-pid ; add the output. To see what it is doing look into strace, getting a backtrace with gdb, or tracing with perf. –  Craig Ringer Apr 18 at 15:21
    
tha hanging pid is on list with text query =idle –  Lord_JABA Apr 20 at 13:03
    
That's weird - in that case you will need to attach to it with gdb and see what it's doing; see wiki.postgresql.org/wiki/… . Or use perf in -g mode to get a profile showing what it's up to. –  Craig Ringer Apr 20 at 13:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.