with transaction() statements have conflicting rollbacks

Bug #125118 reported by Aaron Swartz
2
Affects Status Importance Assigned to Milestone
web.py
Fix Released
Medium
Anand Chitipothu

Bug Description

See http://groups.google.com/group/webpy/browse_thread/thread/4009018b6346ffd3

Perhaps we should take rollback out altogether?

Aaron Swartz (aaronsw)
Changed in webpy:
assignee: nobody → anandology
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Anand Chitipothu (anandology) wrote :

Consider the following code:

def f():
    web.transact()
    try:
        g()
    except:
        web.rollback()
    else:
        web.commit()

def g():
    web.transact()
     h()
     web.commit()

def h():
    raise Exception

Since g, didn't do rollback, the rollback in f is not really rolling back the correct transaction.

How about the following interface?

t = web.transact()
try:
    web.query('blah blah blah')
except:
    t.rollback()
    raise
else:
    t.commit()

Here we know what to rollback, so even if it is rolled back twice, it can be handled.

shall we consider it for web.py 0.3?

Revision history for this message
Anand Chitipothu (anandology) wrote :

Still better:

    t = web.transaction()
    try:
       do_something()
    except:
        t.rollback()
    else:
        t.commit()

if with stmt is supported:

    with web.transaction():
        do_something()

Revision history for this message
Aaron Swartz (aaronsw) wrote : Re: [Bug 125118] Re: with transaction() statements have conflicting rollbacks

I'm not sure what you're saying.

The problem is that db_execute automatically calls rollback.

Aee you saying we should just require people to use with statements?

Revision history for this message
Anand Chitipothu (anandology) wrote :

On Dec 16, 2007 2:42 PM, Aaron Swartz <email address hidden> wrote:
> I'm not sure what you're saying.

I am saying that when you do rollback in a nested transaction, it is
not clear which level you are trying to rollback.
Assuming that rollback will rollback the latest transaction is not
always correct.

> The problem is that db_execute automatically calls rollback.

I fixed it like this.

http://codebrowse.launchpad.net/~anandology/webpy/webpy-0.23/revision/199

>
> Aee you saying we should just require people to use with statements?
>

No.

I am suggesting
    t = db.transaction()
    t.rollback()
instead of
   db.transact()
   db.rollback()

Revision history for this message
Aaron Swartz (aaronsw) wrote :

> I am suggesting
> t = db.transaction()
> t.rollback()
> instead of
> db.transact()
> db.rollback()

Ohhhh.

Clever. That makes sense.

Revision history for this message
Anand Chitipothu (anandology) wrote :

fixed in webpy-0.23. Still need to be fixed in webpy.dev.

Changed in webpy:
milestone: none → 0.3
Changed in webpy:
status: Confirmed → Fix Committed
Changed in webpy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.