Log DBReferenceError in archive_deleted_rows_for_table
We should add the foreign key constraint integrity error to the warning since it includes detailed information about the reference table that caused the constraint failure, which is useful for knowing things are out of order without having to check your database. You get something like this now: 2015-10-07 15:29:38.238 WARNING nova.db.sqlalchemy.api [req-6115aef5-2a82-4d42-bf67-eaab2e8eee63 None None] IntegrityError detected when archiving table instances: (pymysql.err.IntegrityError) (1451, u'Cannot delete or update a parent row: a foreign key constraint fails (`nova`.`instance_actions`, CONSTRAINT `fk_instance_actions_instance_uuid` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`))') [SQL: u'DELETE FROM instances WHERE instances.id in (SELECT T1.id FROM (SELECT instances.id \nFROM instances \nWHERE instances.deleted != %s ORDER BY instances.id \n LIMIT %s) as T1)'] [parameters: (0, 10)] Related-Bug: #1183523 Change-Id: I41b10898c6e9cc48da58c4d2daf7df362fc9fc36
This commit is contained in:
parent
754fe8f460
commit
4a154164da
@ -6017,12 +6017,13 @@ def archive_deleted_rows_for_table(context, tablename, max_rows):
|
||||
with conn.begin():
|
||||
conn.execute(insert)
|
||||
result_delete = conn.execute(delete_statement)
|
||||
except db_exc.DBReferenceError:
|
||||
except db_exc.DBReferenceError as ex:
|
||||
# A foreign key constraint keeps us from deleting some of
|
||||
# these rows until we clean up a dependent table. Just
|
||||
# skip this table for now; we'll come back to it later.
|
||||
msg = _("IntegrityError detected when archiving table %s") % tablename
|
||||
LOG.warn(msg)
|
||||
LOG.warn(_LW("IntegrityError detected when archiving table "
|
||||
"%(tablename)s: %(error)s"),
|
||||
{'tablename': tablename, 'error': six.text_type(ex)})
|
||||
return rows_archived
|
||||
|
||||
rows_archived = result_delete.rowcount
|
||||
|
Loading…
Reference in New Issue
Block a user