Go the following error in a test build:
File "/opt/stack/new/heat/heat/engine/stack.py", line 1528, in _delete_credentials
self.user_creds_id)
File "/opt/stack/new/heat/heat/objects/user_creds.py", line 67, in delete
db_api.user_creds_delete(context, user_creds_id)
File "/opt/stack/new/heat/heat/db/api.py", line 226, in user_creds_delete
return IMPL.user_creds_delete(context, user_creds_id)
File "/opt/stack/new/heat/heat/db/sqlalchemy/api.py", line 688, in user_creds_delete
session.flush()
....
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 728, in _emit_update_statements
(table.description, len(records), rows))
StaleDataError: UPDATE statement on table 'stack' expected to update 7 row(s); 1 were matched
In parallel the purge test was running. What's happening is that sqlalchemy resolves the foreign key and set the user_creds_id to NULL on all stacks referencing the user_creds row being deleted. But if we purge the stacks during the transaction, it fails.
It's probably worth adding a retry around that user_creds_delete call.
Fix proposed to branch: master /review. openstack. org/285425
Review: https:/