Bug 1285359

Summary: nova-manage db archive_deleted_rows doesn't work
Product: Red Hat OpenStack Reporter: Eduard Barrera <ebarrera>
Component: openstack-novaAssignee: Radomir Dopieralski <rdopiera>
Status: CLOSED WONTFIX QA Contact: nlevinki <nlevinki>
Severity: urgent Docs Contact:
Priority: high    
Version: 6.0 (Juno)CC: aguetta, berrange, dasmith, dclarke, ebarrera, eglynn, kchamart, mpryc, mtessun, pablo.iranzo, pneedle, rcernin, rdopiera, sbauza, sferdjao, sgordon, sreber, srevivo, vromanso
Target Milestone: ---Keywords: ZStream
Target Release: 6.0 (Juno)   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-10-20 14:08:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Eduard Barrera 2015-11-25 13:07:17 UTC
Description of problem:

This command to purge the database for deleted instances doesn't work propperly

# nova-manage -v db archive_deleted_rows --max_rows  5000

# tail /var/log/nova/nova-manage.lof

2015-11-25 07:00:26.354 22803 ERROR oslo.db.sqlalchemy.exc_filters [req-24123197-ccae-40ec-aecf-3724a3766599 ] DBAPIError exception wrapped from (IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`nova`.`block_device_mapping`, CONSTRAINT `block_device_mapping_instance_uuid_fkey` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`))') '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)' (0, 5000)
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters Traceback (most recent call last):
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 951, in _execute_context
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters     context)
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 436, in do_execute
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters     cursor.execute(statement, parameters)
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters   File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters     self.errorhandler(self, exc, value)
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters   File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters     raise errorclass, errorvalue
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`nova`.`block_device_mapping`, CONSTRAINT `block_device_mapping_instance_uuid_fkey` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`))')
2015-11-25 07:00:26.354 22803 TRACE oslo.db.sqlalchemy.exc_filters 
2015-11-25 07:00:26.472 22803 WARNING nova.db.sqlalchemy.api [req-24123197-ccae-40ec-aecf-3724a3766599 None] IntegrityError detected when archiving table instances
2015-11-25 07:02:45.735 23181 DEBUG oslo.db.sqlalchemy.session [req-22e5ac3f-6458-4420-859c-1869a06b28a3 ] MySQL server mode set to STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION _check_effective_sql_mode /usr/lib/python2.7/site-packages/oslo/db/sqlalchemy/session.py:482


It is already reported upstream:

https://bugs.launchpad.net/nova/+bug/1296690


Version-Release number of selected component (if applicable):
OSP 6

How reproducible:
always



Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info: