Nested DB transactions |
[eluser]SPeed_FANat1c[/eluser]
I checked CI 2.1.3 and stil it is Code: /** So was this not fixed or is this not a bug. I cannot understand. I did test function: Code: function test_trans() { and model function: Code: public function trans_test() { And everytime trans depth is 0. But in reality postgre log file shows WARNING 2012-11-08 16:22:20 EET WARNING: there is already a transaction in progress so it tries nested transaction which does not work in PostgreSQL. I completely do not understand. I started searching because in our application we are getting such warnings. So I want to detect where are they. I think transaction depth should be more than 0 when there is attempt to start inside transaction, but as I see from my test functions I cannot detect that. I dont't even understand from the documentation if ci supports nested transactions or not: Quote:Traditionally, transactions have required a fair amount of work to implement since they demand that you to keep track of your queries and determine whether to commit or rollback based on the success or failure of your queries. This is particularly cumbersome with nested queries. In contrast, we've implemented a smart transaction system that does all this for you automatically (you can also manage your transactions manually if you choose to, but there's really no benefit). It mentions nested queries. Nested queries = nested transactions ? From the code snippets it looks that it should not support. When trans deph is > 0 - return, - so do not start another transaction. But it starts because depth does not get over 0 anytime. From what I found by googling - it looks like it does not support them, but supports savepoints which I don't know well what they differ from transactions yet. http://www.postgresql.org/docs/current/i...tions.html http://postgresql.1045698.n5.nabble.com/...25789.html But then if it does not support - what does this comment mean: Quote:// When transactions are nested we only begin/commit/rollback the outermost ones So transactions still can be nested in CI? And same is in postgre_driver.php Is this a bug not fixed for such long time or is this not a bug? Also - what strategy to use to catch where those transactions become nested when they should not be? In our application we had no intention of doing nested transactions, but could make bugs. For example we get 2 messages in a row in logs: 2012-11-08 08:51:02 EET WARNING: there is already a transaction in progress 2012-11-08 08:51:02 EET WARNING: there is no transaction in progress So it looks like it tries to start inside transaction, but postgre does not allow to do that. Then code does not break, it continues and reaches trans_complete. Then interesting - where that starting transaction finishes? If we look at time, its at the same second. Mayeb could be something like this: Code: some_function() { so when we start the transaction, some_function() also tries to run trnasaction, gets warnign, then tries to complete, - it completes the transaction started eearlier. At this point there is no started transaction. some_function() finishes doing stuff And then after this thre is last trans_complete call. But transaction is already finished by the some_function, so it gets warning. |
Messages In This Thread |
Nested DB transactions - by El Forum - 01-08-2009, 05:00 AM
Nested DB transactions - by El Forum - 01-08-2009, 06:10 AM
Nested DB transactions - by El Forum - 01-08-2009, 08:21 AM
Nested DB transactions - by El Forum - 02-28-2009, 09:27 PM
Nested DB transactions - by El Forum - 02-28-2009, 09:41 PM
Nested DB transactions - by El Forum - 02-28-2009, 09:58 PM
Nested DB transactions - by El Forum - 03-03-2009, 04:39 AM
Nested DB transactions - by El Forum - 03-24-2009, 03:54 PM
Nested DB transactions - by El Forum - 03-25-2009, 08:13 PM
Nested DB transactions - by El Forum - 05-24-2009, 09:24 AM
Nested DB transactions - by El Forum - 10-23-2010, 06:42 AM
Nested DB transactions - by El Forum - 11-08-2012, 07:57 AM
|