we have a php script that runs this console command
cat import.sql | mysql -u user -ppassword
so it simply imports a file in to the DB
the file is quite big ~ 120 mb
but it contains only insert/replace queries like this one:
/*!40000 ALTER TABLE `actionList` DISABLE KEYS */;
REPLACE INTO `actionList` VALUES (1,'buttonClick','Click on a button'),(2,'buttonClose','Click on the close button');
/*!40000 ALTER TABLE `actionList` ENABLE KEYS */;
I removed the lock table from the code.
Now when this script is running my other pages cant load until this script is finished.
Any ideas why this is happening?
This wasn't a DB lock it was the session lock.
As we ran the script it took a lot of time, and the session was open, so other pages try to use the session but couldn't.
So I added:
session_write_close();
and it solved the problem.
Use different password for import process and do not import as root user.
Also you can limit the user :
mysql> CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank';
mysql> GRANT ALL ON customer.* TO 'francis'@'localhost'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2;
For more information : http://dev.mysql.com/doc/refman/5.0/en/user-resources.html