Project

General

Profile

Actions

Bug #9010

open

[paddles] `rollback()` is used incorrectly

Added by Alfredo Deza over 9 years ago. Updated over 8 years ago.

Status:
New
Priority:
Normal
Assignee:
Category:
-
% Done:

0%

Source:
Development
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Crash signature (v1):
Crash signature (v2):

Description

In places like `paddles/controllers/runs.py` there are try/except blocks that catch non-altering database actions
that call `rollback()` which is meant to "roll back a transaction". It is usually there so that when a transaction that
is going to do a delete, update, or create action that requires a commit and that action creates an error it can be "rolled back".

This is an example of wrong usage of rollback:

def latest_runs(fields=None, count=conf.default_latest_runs_count, page=1):
    query = Run.query.order_by(Run.posted.desc())
    query = offset_query(query, page_size=count, page=page)
    runs = query.all()
    if fields:
        try:
            return [run.slice(fields) for run in runs]
        except AttributeError:
            rollback()
            error('/errors/invalid/',
                  'an invalid field was specified')
    return [run for run in runs]
Actions #1

Updated by Ian Colle over 9 years ago

  • Project changed from devops to teuthology
Actions #2

Updated by Zack Cerza over 9 years ago

  • Status changed from New to Need More Info
  • Assignee deleted (Zack Cerza)

I still don't agree that I'm necessarily using it incorrectly; there is at least one instance where I had to add it because pecan was explicitly throwing an error telling me to do so.

Actions #3

Updated by Alfredo Deza about 9 years ago

Would you mind showing what you say Pecan was suggesting? The Paddles app uses a hook that should handle these
when there is an HTTP verb that should affect data (e.g. POST, DELETE, PUT), the hook may not operate if for example
there is a GET operation and data is getting modified.

The pasted example in the description is just one place, this is done in a few others as well.

Actions #4

Updated by Dan Mick over 8 years ago

  • Status changed from Need More Info to Closed
  • Regression set to No

If this is still an issue, reopen.

Actions #5

Updated by Alfredo Deza over 8 years ago

  • Status changed from Closed to 12

Unfortunately this is still an issue:

~/python/paddles/paddles$ grep -A 1 -B 1 -Hrn 'rollback()' *
...
controllers/jobs.py-99-            except AttributeError:
controllers/jobs.py:100:                rollback()
controllers/jobs.py-101-                error('/errors/invalid/',
--
--
controllers/jobs.py-114-        except ValueError:
controllers/jobs.py:115:            rollback()
controllers/jobs.py-116-            error('/errors/invalid/', 'could not decode JSON body')
--
--
controllers/nodes.py-50-        except ValueError:
controllers/nodes.py:51:            rollback()
controllers/nodes.py-52-            error('/errors/invalid/', 'could not decode JSON body')
--
--
controllers/runs.py-24-        except AttributeError:
controllers/runs.py:25:            rollback()
controllers/runs.py-26-            error('/errors/invalid/',
--
--
controllers/runs.py-48-        except ValueError:
controllers/runs.py:49:            rollback()
controllers/runs.py-50-            error('/errors/invalid/', 'date format must match %s' %
--
--
controllers/runs.py-286-        except ValueError:
controllers/runs.py:287:            rollback()
controllers/runs.py-288-            error('/errors/invalid/', 'could not decode JSON body')
Actions #6

Updated by Alfredo Deza over 8 years ago

  • Status changed from 12 to New
Actions #7

Updated by Dan Mick over 8 years ago

  • Assignee set to Zack Cerza
Actions

Also available in: Atom PDF