nova-manage db archive_deleted_rows doesn't check for negative max_rows

Bug #1145609 reported by Joe Gordon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Joe Gordon

Bug Description

From latest devstack on 2013-3-4

box:~/devstack$ sudo nova-manage db archive_deleted_rows --max_rows -5

Command failed, please check log for more info

2013-03-05 00:49:41.631 CRITICAL nova [req-ee44b54f-27b5-473b-8349-4ab42f95d725 None None] (ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-5' at line 4") 'SELECT aggregate_metadata.created_at, aggregate_metadata.updated_at, aggregate_metadata.deleted_at, aggregate_metadata.id, aggregate_metadata.aggregate_id, aggregate_metadata.`key`, aggregate_metadata.value, aggregate_metadata.deleted \nFROM aggregate_metadata \nWHERE aggregate_metadata.deleted != %s ORDER BY aggregate_metadata.id \n LIMIT %s' (0, -5)
2013-03-05 00:49:41.631 8904 TRACE nova Traceback (most recent call last):
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/local/bin/nova-manage", line 7, in <module>
2013-03-05 00:49:41.631 8904 TRACE nova execfile(__file__)
2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/bin/nova-manage", line 1247, in <module>
2013-03-05 00:49:41.631 8904 TRACE nova main()
2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/bin/nova-manage", line 1239, in main
2013-03-05 00:49:41.631 8904 TRACE nova fn(*fn_args, **fn_kwargs)
2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/bin/nova-manage", line 800, in archive_deleted_rows
2013-03-05 00:49:41.631 8904 TRACE nova db.archive_deleted_rows(admin_context, max_rows)
2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/nova/db/api.py", line 1705, in archive_deleted_rows2013-03-05 00:49:41.631 8904 TRACE nova return IMPL.archive_deleted_rows(context, max_rows=max_rows)
2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 95, in wrapper
2013-03-05 00:49:41.631 8904 TRACE nova return f(*args, **kwargs)
2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 4779, in archive_deleted_rows
2013-03-05 00:49:41.631 8904 TRACE nova max_rows=max_rows - rows_archived)
2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 95, in wrapper2013-03-05 00:49:41.631 8904 TRACE nova return f(*args, **kwargs)2013-03-05 00:49:41.631 8904 TRACE nova File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 4751, in archive_deleted_rows_for_table
2013-03-05 00:49:41.631 8904 TRACE nova rows = conn.execute(query).fetchall()
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1449, in execute
2013-03-05 00:49:41.631 8904 TRACE nova params)
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement
2013-03-05 00:49:41.631 8904 TRACE nova compiled_sql, distilled_params
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context
2013-03-05 00:49:41.631 8904 TRACE nova context)
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
2013-03-05 00:49:41.631 8904 TRACE nova context)
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 331, in do_execute
2013-03-05 00:49:41.631 8904 TRACE nova cursor.execute(statement, parameters)
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
2013-03-05 00:49:41.631 8904 TRACE nova self.errorhandler(self, exc, value)
2013-03-05 00:49:41.631 8904 TRACE nova File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2013-03-05 00:49:41.631 8904 TRACE nova raise errorclass, errorvalue
2013-03-05 00:49:41.631 8904 TRACE nova ProgrammingError: (ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-5' at line 4") 'SELECT aggregate_metadata.created_at, aggregate_metadata.updated_at, aggregate_metadata.deleted_at, aggregate_metadata.id, aggregate_metadata.aggregate_id, aggregate_metadata.`key`, aggregate_metadata.value, aggregate_metadata.deleted \nFROM aggregate_metadata \nWHERE aggregate_metadata.deleted != %s ORDER BY aggregate_metadata.id \n LIMIT %s' (0, -5)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/23496

Changed in nova:
assignee: nobody → Joe Gordon (jogo)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/23496
Committed: http://github.com/openstack/nova/commit/abc0c9479127671adf8fcd81197ab993356cbc6a
Submitter: Jenkins
Branch: master

commit abc0c9479127671adf8fcd81197ab993356cbc6a
Author: Joe Gordon <email address hidden>
Date: Tue Mar 5 01:11:45 2013 +0000

    Make nova-manage db archive_deleted_rows more explicit

    * max_rows must be positive
        Provide a better error message of 'nova-manage db archive_deleted_rows
        --max_rows=' is negative.
    * Requires a max_rows
    * No hidden default of 5000

    Fix bug 1145609
    Fix bug 1151064

    Change-Id: I9078ff2700a0329ac4aff68bb434be5f16a5a3f1

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → grizzly-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-rc1 → 2013.1
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.