» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 08-05-2006, 06:41 AM
Marie Marie is offline
Junior Member
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Marie is on a distinguished road
Default deadlock problems....???

Hi,
I am looking for the "cause" behind a deadlock which occur quite frequently. It can be reproduced in the following manner:

CREATE TABLE test (
id bigint(20) NOT NULL auto_increment,
id2 bigint(20) NOT NULL default 0,
str varchar(255) default NULL,
PRIMARY KEY (id),
KEY id2 (id2)
) ;

Insert few records:
INSERT INTO test (id2, str) VALUES (1, 'tim');
INSERT INTO test (id2, str) VALUES (2, 'tom');
INSERT INTO test (id2, str) VALUES (3, 'jim');
INSERT INTO test (id2, str) VALUES (4, 'neo');
INSERT INTO test (id2, str) VALUES (5, 'ken');

Consider two threads T1 and T2 performing the following operations in the sequence specified below:

T1: BEGIN;

T2: BEGIN;

T1: DELETE FROM test WHERE id2 = 2;

T2: DELETE FROM test WHERE id2 = 3;

T1: INSERT INTO test (id2, st -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-05-2006, 06:45 AM
Beau Beau is offline
Senior Member
 
Join Date: Jul 2006
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 16
Beau is on a distinguished road
Default

the two delete statement causes exclusive next-key lock on index id2.
when tx1 want to insert, it needs shared next-key lock, which is held by tx2, so tx1 hang;
when tx2 want to insert, it needs shared next-key lock too, which is held by tx1, so dead lock, tx2 rollback

try to remove the next-key locks with the my.cnf option:

innodb_locks_unsafe_for_binlog

also, read the caveats in the manual. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
i m facing ranking problems jig123 Yahoo 5 07-22-2008 09:10 AM
Problems With Updating DNS longhornfreak Web Hosting Industry 0 02-16-2007 11:17 PM
problems with Google Toolbar recently? hunter Google 3 09-18-2006 02:19 PM
Problems using functions w/ parameters dan ASP forums and Tips 1 08-19-2006 10:18 AM
Problems connecting to mysqld from mysql carri MySQL Forums 1 12-08-2005 04:01 AM


All times are GMT. The time now is 09:04 PM.