yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #21790
[Bug 1067683] Re: When unique constraint error occured, exception of NovaBase.save() raising cause is sqlalchemy.exc.IntegrityError.
** No longer affects: nova/folsom
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1067683
Title:
When unique constraint error occured, exception of NovaBase.save()
raising cause is sqlalchemy.exc.IntegrityError.
Status in OpenStack Compute (Nova):
Fix Released
Bug description:
Now, when unique constraint error occured, sqlalchemy.exc.IntegrityError is raised without entering through the else branch if statement.
Exception eventually receive nova.exception.DBError, because it is rapped in get_session() of nova/db/sqlalchemy/session.py
def save(self, session=None):
"""Save this object."""
if not session:
session = get_session()
session.add(self)
try:
session.flush()
except IntegrityError, e:
if str(e).endswith('is not unique'):
raise exception.Duplicate(str(e))
else:
raise
[error log]
======================================================================
FAIL: test_session_flush_on_integrity_violation()
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/stack/tempest/tempest/manual_tests/negative_st/test_negative_sqlalchemy.py", line 159, in test_session_flush_on_integrity_violation
self.assertEqual(exception.Duplicate, inner_ex.__class__)
AssertionError: <class 'nova.exception.Duplicate'> != <class 'sqlalchemy.exc.IntegrityError'>
-------------------- >> begin captured logging << --------------------
tempest.config: INFO: Using tempest config file /opt/stack/tempest/etc/tempest.conf
nova.exception: ERROR: DB exception wrapped.
Traceback (most recent call last):
File "/opt/stack/nova/nova/exception.py", line 68, in _wrap
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1547, in flush
self._flush(objects)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1616, in _flush
flush_context.execute()
File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 328, in execute
rec.execute(self)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 472, in execute
uow
File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 2264, in _save_obj
execute(statement, multiparams)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1405, in execute
params)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1538, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1646, in _execute_context
context)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1639, in _execute_context
context)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 330, in do_execute
cursor.execute(statement, parameters)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
IntegrityError: (IntegrityError) (1062, "Duplicate entry '9' for key 'PRIMARY'") 'INSERT INTO services (created_at,
updated_at, deleted_at, deleted, id, host, `binary`, topic, report_count, disabled, availability_zone) VALUES (%s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2012, 9, 13, 2, 16, 22, 105645), None, None, 0, 9L,
None, None, None, 0, 0, 'nova')
Reason of bug seems to be to coming out of sqlarchemy error without being rapped in a nova.
I think should return nova.exception.Duplicate.
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1067683/+subscriptions