home / django_tickets / tickets

tickets: 2227

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
2227 2006-06-23 11:19:03 2013-03-11 14:40:48 2022-03-06 03:25:24.995146 Accepted closed Database layer (models, ORM) New feature Normal dev fixed transaction.commit()/rollback() should be aware of nested calls to transaction.managed(True) As I see in the transaction.py, commit()/rollback() call connection._commit()/connection._rollback() explicitly. It breaks the case when a function with commit_manually or commit_on_success decorator calls another function decorated the same way (enters the transaction management). Consider following scenario: {{{ # a bank account class class Account: @transaction.commit_on_success def withdraw(self, sum): # code to withdraw money from the account @transaction.commit_on_success def add(self, sum): # code to add money to the account # somewhere else @transaction.commit_on_success def makeMoneyTransaction(from_account, to_account, sum): # this code will call commit on success from_account.withdraw(sum) # this code may raise an exception, and if it raises, # commit won't be called in Account.add() and makeMoneyTransaction() # But money had been already withdrawn, and the from_account saved in the database. # The makeMoneyTransaction's transaction is inconsistent. # So we loose our money to_account.add(sum) }}} IMO, what the transaction.commit should do in this case is to check first whether the transaction is "nested". In the [http://adodb.sourceforge.net/ AdoDB] PHP library, each call to StartTrans either starts new transaction or increments the counter of the nested StartTrans calls. CompleteTrans either calls commit/rollback (if its StartTrans counterpart was not called inside another StartTrans/CompleteTrans block) or decrements the counter. I rate this deficiency as major. What do you think? aaugustin mderk@yandex.ru transaction, nest, scope, nested, rollback, commit 0 1 1 0 0 0
Powered by Datasette · Queries took 0.84ms