Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > mysqli auto rollback on script termination
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 27th February 09:40
martin@925.dk (martin koch
External User
 
Posts: 1
Default mysqli auto rollback on script termination



Hi,

In case the PHP script dies (from fatal error, die() or similar), is any
started transaction (BEGIN TRANSACTION) automatically rolled back
(ROLLBACK) by PHP then?

I can't find any do***entation about this.

Thanks in advance for hints, links etc.

--
Martin - http://925.dk
"Shoot for the moon, even if you miss, you'll land among the stars."
  Reply With Quote


  sponsored links


2 27th February 09:40
dmagick@gmail.com
External User
 
Posts: 1
Default mysqli auto rollback on script termination



It should be rolled back when a connection is lost or a transaction
isn't ********ly committed.

Whether that's a php script dying or the server being shut down
mid-transaction or anything similar (eg a remote server's lan connection
goes down).

Of course this assumes you're using innodb tables and not myisam -
myisam doesn't support transactions..

--
Postgresql & php tutorials
http://www.designmagick.com/
  Reply With Quote
3 27th February 09:40
martin@925.dk (martin koch
External User
 
Posts: 1
Default mysqli auto rollback on script termination


Chris skrev:

Can you find do***entation on this specific issue anywhere?

I think the same as you, but I find it odd, it is not do***ented.

Reason I'm asking is, I've seen some deadlock issues in a script (using
FOR UPDATE and LOCK IN SHARE MODE), that looks like they are caused by
transactions not being rolled back (releasing locks) correctly.

--
Martin - http://925.dk
"Shoot for the moon, even if you miss, you'll land among the stars."
  Reply With Quote
4 27th February 09:40
dmagick@gmail.com
External User
 
Posts: 1
Default mysqli auto rollback on script termination


This suggests they should be released:
http://dev.mysql.com/doc/refman/4.1/en/innodb-locking-reads.html

Locks set by IN SHARE MODE and FOR UPDATE reads are released when the
transaction is committed or rolled back.


It doesn't ********ly say anything about when a connection is lost but
I'm guessing it would rollback the transaction (well I'd sure hope so).

--
Postgresql & php tutorials
http://www.designmagick.com/
  Reply With Quote
5 27th February 09:40
martin@925.dk (martin koch
External User
 
Posts: 1
Default mysqli auto rollback on script termination


Chris skrev:

Me too. In any case, I'm now also using register_shutdown_function,
which calls a function that does rollback of not committed transations.

Thanks.

--
Martin - http://925.dk
"Shoot for the moon, even if you miss, you'll land among the stars."
  Reply With Quote
6 27th February 09:40
felho@avalon.aut.bme.hu (hodicska
External User
 
Posts: 1
Default mysqli auto rollback on script termination


Do you use pconnect? If I right remember there was a bug in some version
of mysql that in the case of using pconnect in some cases the automatic
rollback didn't happen. The solution was: after pconnect one had to
start with a rollback command.


Regards,
Felhő
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666