From: Dmitry Lenev Date: June 21 2012 7:08pm Subject: Re: purpose of thd_mark_transaction_to_rollback List-Archive: http://lists.mysql.com/internals/38539 Message-Id: <20120621190856.GA21801@jubjub> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hello Zardosht! * Zardosht Kasheff [12/06/20 21:30]: > Hello Dmitry, >=20 > Thank you for your response. Why does InnoDB do this when a deadlock > is detected? Well... This is one of possible reasonable ways to address deadlock problem. Of course, there is an alternative approach - to rollback only current statement, report error to user and rely on user doing rollback or other correcting action. But it has its own drawbacks. > Does every storage engine need to do this? Is this part > of some specification that calls for this? Or is it some sort of > performance optimization? AFAIU engine needs to call thd_mark_transaction_to_rollback() if he wants to initiate rollback of transaction, but the decision whether to rollback the whole transaction or only one statement is, in my opinion, up to the storage engine writer. Regards, Dmitry >=20 > Thanks > -Zardosht >=20 > On Tue, Jun 19, 2012 at 3:53 PM, Dmitry Lenev = wrote: > > Hello Zardosht! > > > > * Zardosht Kasheff [12/06/19 22:20]: > >> Hello all, > >> > >> What is the purpose of thd_mark_transaction_to_rollback? > > > > This call allows storage engine to request a transaction/statement > > rollback from SQL-layer. > > > > For example, when InnoDB storage engine detects a deadlock it rolls > > back the transaction inside storage engine (i.e. itself), but it stil= l > > needs to invoke this method so transaction is properly rolled back > > in other storage engines (including binary log). > > > >> Under what conditions is a storage engine required to call this func= tion? > > > > See above. I guess it is good idea to call this method when your > > storage engine decides to initiate a transaction rollback because > > of internal reasons, i.e. in case when such a rollback is not > > explicitly initiated from SQL-layer. > > > > Hope this helps! > > > > -- > > Dmitry Lenev, Software Developer > > Oracle Development SPB/MySQL, www.mysql.com > > > > Are you MySQL certified? =A0http://www.mysql.com/certification --=20 Dmitry Lenev, Software Developer Oracle Development SPB/MySQL, www.mysql.com Are you MySQL certified? http://www.mysql.com/certification