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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.