Real nested db transactions

122 views
Skip to first unread message

Juan Basso

unread,
Apr 1, 2012, 12:49:03 AM4/1/12
to cakeph...@googlegroups.com
Hey guys,

I changed the core to support real nested transactions when the driver support it. I checked that Sqlite, MySQL and Postgres support it. SQL Server also support, but not with PDO. I made a change that should not affect any app or class that extend the DboSource.



Juan Basso

Vitor Pacheco

unread,
Apr 1, 2012, 1:24:54 AM4/1/12
to cakeph...@googlegroups.com
+1
Juan, really good work!

2012/4/1 Juan Basso <jrb...@gmail.com>



--
Vitor Pacheco
Skype: vitor.pacheco.costa
Msn: vito...@hotmail.com
GTalk: vitor...@gmail.com
Cel.: 71 8626-7909
Tel.: 71 3378-5778 /
 71 3287-3475

José Lorenzo Rodríguez

unread,
Apr 1, 2012, 12:17:48 PM4/1/12
to cakeph...@googlegroups.com
This is super cool, great work Juan. My only concern is that you do not always want to have checkpoints as they are Somewhat expensive for the database manager.

Sometimes having the ability to fake transactions is enough for the user (and in general for internal CakePHP needs such as loading fixtures)

I would offer the ability of using both types, faked and real transaction nesting and making the fake ones the default. If anyone need a more advanced approach to transactions they can just enable it.

What do you think?

Sent from my iPhone

mark_story

unread,
Apr 1, 2012, 2:03:03 PM4/1/12
to cakeph...@googlegroups.com
How would that work josé? 

-Mark

José Lorenzo Rodríguez

unread,
Apr 1, 2012, 3:18:13 PM4/1/12
to cakeph...@googlegroups.com
That is already there, I added fake nested transaction support in 2.0. I'm just suggesting to make that the default.

Just take a look at the functions Juan modified, the logic behind it is pretty simple: add to a counter each time a transaction is begun, only commit if the same number of commit() calls have been made, and always rollback no matter how deep you are in the transactions tree.


Sent from my iPhone

Juan Basso

unread,
Apr 1, 2012, 4:45:18 PM4/1/12
to cakeph...@googlegroups.com
@mark: the old behavior is the same of when the driver do not support nested transactions. As Jose's explained.

About the default behavior be the fake one, don't you think it is a little annoying or frustrating for users once everything works as "expected", except that it doesn't work with database until you enable it? I guess is a small portion of users that use nested transactions, so if these users are expecting [performance] issues, they can disable it.


Juan Basso


2012/4/1 José Lorenzo Rodríguez <jose...@gmail.com>

Juan Basso

unread,
Apr 14, 2012, 5:53:16 PM4/14/12
to cakeph...@googlegroups.com
I added the option to disable the nested transactions. Also, updated the book.


Juan Basso

mark_story

unread,
Apr 16, 2012, 1:48:07 PM4/16/12
to cakeph...@googlegroups.com
It looks good to me Juan.  I wonder if things like nestedTransaction, logQuery and other properties on the datasources, could/should be moved into the configuration part of the datasource.  Seems like those options are configuration data, and its a pain to have config data in two places.  Perhaps we wait on that until 3.0 though.

-Mark

ADmad

unread,
Apr 16, 2012, 4:37:07 PM4/16/12
to cakeph...@googlegroups.com
I had the same thoughts, it would be better to have nestedTransaction as a config param.

-ADmad
Reply all
Reply to author
Forward
0 new messages