mysqli auto rollback on script termination
mysqli auto rollback on script termination
am 09.10.2006 06:26:21 von Martin Koch Andersen
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 documentation 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."
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: mysqli auto rollback on script termination
am 09.10.2006 07:37:06 von Chris
Martin Koch Andersen wrote:
> 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?
It should be rolled back when a connection is lost or a transaction
isn't explicitly 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/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: mysqli auto rollback on script termination
am 09.10.2006 13:20:38 von Martin Koch Andersen
Chris skrev:
> It should be rolled back when a connection is lost or a transaction
> isn't explicitly committed.
Can you find documentation on this specific issue anywhere?
I think the same as you, but I find it odd, it is not documented.
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."
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: mysqli auto rollback on script termination
am 10.10.2006 02:49:38 von Chris
Martin Koch Andersen wrote:
> Chris skrev:
>> It should be rolled back when a connection is lost or a transaction
>> isn't explicitly committed.
>
> Can you find documentation on this specific issue anywhere?
>
> I think the same as you, but I find it odd, it is not documented.
>
> 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.
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 explicitly 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/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: mysqli auto rollback on script termination
am 10.10.2006 14:38:26 von Martin Koch Andersen
Chris skrev:
> It doesn't explicitly say anything about when a connection is lost but
> I'm guessing it would rollback the transaction (well I'd sure hope so).
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."
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: mysqli auto rollback on script termination
am 10.10.2006 23:22:00 von Hodicska Gergely
> 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.
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Å
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php