Click here to get back home

Deadlock handling in InnoDB

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Deadlock handling in InnoDB Alex 09-07-2005
Get Chitika Premium
Posted by Alex on September 7, 2005, 8:46 am
Please log in for more thread options
I was hoping someone could confirm my understanding of how InnoDB
handles deadlocks (error 1213) and timeouts (error 1206). The way I
understand it, with AUTOCOMMIT=0, if I issue 3 SQL statements
(updates), A, B, and C (in that order), and get one of the errors above
while issuing statement C, InnoDB will have rolled back statements A
and B. To recover from this error condition, I need to re-issue
statements A and B, followed by C. Then, if all three go through, I
can call COMMIT and have A, B, and C committed. Is this correct?

Thank you in advance,

Alex



Posted by Bill Karwin on September 7, 2005, 10:43 am
Please log in for more thread options
Alex wrote:
> I was hoping someone could confirm my understanding of how InnoDB
> handles deadlocks (error 1213) and timeouts (error 1206). The way I
> understand it, with AUTOCOMMIT=0, if I issue 3 SQL statements
> (updates), A, B, and C (in that order), and get one of the errors above
> while issuing statement C, InnoDB will have rolled back statements A
> and B. To recover from this error condition, I need to re-issue
> statements A and B, followed by C. Then, if all three go through, I
> can call COMMIT and have A, B, and C committed. Is this correct?

Read these pages:
http://dev.mysql.com/doc/mysql/en/innodb-error-handling.html
http://dev.mysql.com/doc/mysql/en/innodb-deadlock-detection.html

"A transaction deadlock or a timeout in a lock wait causes InnoDB to
roll back the whole transaction."

That seems to support your understanding. Yes, if statement C in your
scenario causes a deadlock or timeout error, then the whole transaction
is rolled back. This includes the uncommitted work done in the same
transaction by the statements A and B.

The documentation admits that this behavior is not in accordance with
the SQL standard.

Regards,
Bill K.


Posted by Alex on September 7, 2005, 2:40 pm
Please log in for more thread options
Thank you, Bill. My understanding comes from the same docs you're
citing. I at one point was misinterpreting the above, thinking that
only statement C would need to be re-issued, so wanted to confirm that
my newfangled interpretation was correct. Sounds like there's at least
one other person who understands it the same way I do. :-)

Can anyone else offer a 'definitive' confirmation or refutal?

Thank you in advance,

Alex



Similar ThreadsPosted
Deadlock found when trying to get lock (MySQL 5.0 with innodb) December 10, 2006, 11:59 pm
Deadlock error May 8, 2006, 1:22 am
innodb being skipped without skip-innodb December 28, 2006, 4:03 pm
MyISAM versus Innodb - help me!! July 6, 2005, 12:46 pm
Innodb 150 million records September 11, 2005, 1:31 pm
InnoDB Weekly Backups February 9, 2006, 12:59 pm
InnoDB + AUTO_INCREMENT questions. April 25, 2006, 5:04 am
Innodb slave Insert Performance June 29, 2005, 11:22 am
Database Restore / MySQL 4.1 -- InnoDB May 1, 2006, 12:11 pm
InnoDB, 4.1.20, INS/DEL/TX -- Why table-level locking? July 7, 2006, 9:43 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap