# locking



## drewer (Mar 14, 2018)

Hi @all 

On command top I have sometimes a number of locks displayed (eg.46)

How can I find out what these locks are?


----------



## SirDice (Mar 14, 2018)

Please post an example, keep in mind that we can't look at your screen so we have no idea what you're looking at. 

Also report the version of FreeBSD.


----------



## ykla (Mar 14, 2018)

Sorry , but you have to post some pictures.


----------



## drewer (Mar 15, 2018)

background information:
i see this not very often... but the locks slow down the system .. i post a fake image.. when it happends also the cpu usage of system goes up to 99% and computer is unrespondable (i used cpuset to exclude one or two cores ..  then i kill some processes like apache and php .. after this ... the locks goes down 0 and normal cpu usages )


----------



## SirDice (Mar 15, 2018)

Those are probably resource locks. This can happen for example when a process wants more memory but the system doesn't have it any more. As you're running MySQL my first guess would be a badly tuned MySQL which tries to use more memory than the system actually has.


----------



## drewer (Mar 16, 2018)

Thanks for your advise... 
mysqltuner say that MySQL can max use of 5.1 GB ram and max reached is 3.6 GB.. (system has 32 GB)

Can resource locks also can be CPU or filesystem (ZFS) based?

I am not sure, is it the right way find out what these locks are or should I find out what's the high system CPU usage is? It is a chicken <-> egg problem.


----------



## SirDice (Mar 16, 2018)

drewer said:


> mysqltuner say that MySQL can max use of 5.1 GB ram and max reached is 3.6 GB.. (system has 32 GB)


Ok, that's good. I've seen some really bad configurations where MySQL was configured to use 100GB while the machine only had 12GB. And that's obviously going to cause problems.


drewer said:


> Can resource locks also can be CPU or filesystem (ZFS) based?


It could be anything really. Try and get the actual numbers, not something you remembered, we can probably tell what's what if we have the original output. 



drewer said:


> I am not sure, is it the right way find out what these locks are or should I find out what's the high system CPU usage is?


I would definitely start there, it's not normal for MySQL to use 99% CPU. So something fishy is going on. Look at the process list of MySQL: `SHOW PROCESSLIST;`. Look for abnormal queries or queries that have been running a really long time. If the MySQL database is used for some web application take a really good look at that too, SQL-injection problems are common in badly written web applications.


----------

