kestasjk Posted November 18, 2006 Share Posted November 18, 2006 [code]<?phpset_time_limit(5);// The script ends if it goes on for 5 secsmysql_query("SELECT GET_LOCK('somelock', 10)");// Try to get the lock, wait for 10 secs to get it. If we can't get it within the 5 secs we have the script fails as we intend.// Code which must be ACID here?>[/code]I was relying on the above to keep a transaction ACID, but I didn't realize that [quote]The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself.[/quote]The script itself [b]doesn't include calls the script makes[/b]. To me this is incredibly counter intuitive.[code]<?phpset_time_limit(1);set_ini('max_execution_time', 1);sleep(50);print "Surely this print command will never get run?!";?>[/code]The print command will get run.. incredible.After having spent the last 3 hours tracking down a weird bug which I thought could only have been caused by an ACID violation I'll now have to spend the next hour trying to manually undo the damage done.Use:[code]<?phplist($success) = mysql_table(mysql_query("SELECT GET_LOCK('somelock', 10)"));if ($success == 1) {// Code which must be ACID here}?>[/code]or use "LOCK TABLES asdf write, foobar write" Quote Link to comment Share on other sites More sharing options...
fenway Posted November 19, 2006 Share Posted November 19, 2006 I've never used GET_LOCK()... was this thread a word to the wise, or did I miss the question? Quote Link to comment Share on other sites More sharing options...
kestasjk Posted November 20, 2006 Author Share Posted November 20, 2006 It was just a word to the wise, hopefully when someone else gets a similar problem and google it they'll get this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.