0

I am using Ubuntu 18.04 with PHP application connected to MySQL database. Often, using Mytop, I detect some stuck MySQL threads:

   Id      User         Host/IP         DB       Time     Cmd    State 
   --      ----         -------         --       ----     ---    ----- 
1725310  ms_db_use  184.126.65.142   app_pro     19716   Sleep
2370165  ms_db_use  localhost:58210  app_pro      1385   Query   Copying 

As you can see above, some threads are stucked for 19k seconds. This is putting overload on my cpu sometimes so my question is:

Is there any way to automate this to automatically kill the thread if it is not resolved in X Amount of seconds? The purpose of this is to remove overload from CPU.


According to this it is PHP application on my server, just I am not sure how to troubleshoot that part:

PID USER PRI VIRT RES SHR S CPU MEM% COMMAND 124 megax 20 335M 19254 21212 S 100.00% 0.0 php-fpm: pool www 125 megax 20 335M 19254 21212 S 100.00% 0.0 php-fpm: pool www 126 megax 20 335M 19254 21212 S 100.00% 0.0 php-fpm: pool www 127 megax 20 335M 19254 21212 S 100.00% 0.0 php-fpm: pool www

Martin
  • 22,212
  • 11
  • 70
  • 132
  • 1
    Cmd `Sleep` it appears not to be doing anything anyway, it's probably waiting for a call so is not using CPU much. – Martin Sep 19 '20 at 12:57
  • 1
    I don't see anything there to worry about especially if you are not seeing high CPU usage. – Dave Sep 19 '20 at 12:58
  • actually i see high cpu usage whenever i am having mysql thread in idle from localhost – Ultra Sharing Sep 19 '20 at 14:01
  • Please post your complete htop or top first page of output so we can see what you are observing. KILLING things is not a generally recommended procedure. Much damage can be done to your system. – Wilson Hauck Sep 19 '20 at 14:59

0 Answers0