Jump to content

Deadlocks


pernest

Recommended Posts

Hi

 

I was hoping that someone could advise me if the following code in my php script could (under the right wrong circumstances) be generating a deadlock?

 

Working with latest WAMP

 

My data base contains two tables, "products" and "reviews", and my script has the code:

 

mysql_query("LOCK TABLES products,reviews WRITE");
mysql_query("INSERT INTO products blah blah blah");
mysql_query("INSERT INTO reviews blah blah blah");
mysql_query("UNLOCK TABLES");

 

I think that running a single copy of this script would be fine, but I am trying to run ten copies concurrently. They will run successfully for 2 to 8 hours, then then freeze.

 

Is it possible that one script could get a lock on products, and the the other get a lock on reviews, but that each script would then be looking for a lock on the other table?

 

If this could be generating a deadlock, then how could I modify it to remove this problem?

 

Many thanks

Link to comment
https://forums.phpfreaks.com/topic/176558-deadlocks/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.