nova/nova/db/sqlalchemy
Matthew Booth 4540cd6ef9 Fix retry of instance_update_and_get_original
_instance_update modifies its 'values' argument. Consequently if it is
retried due to an update conflict, the second invocation has the wrong
arguments.

A specific issue this causes is that if we called it with
expected_task_state a concurrent modification to task_state will cause
us to fail and retry. However, expected_task_state will have been popped
from values on the first invocation and will not be present for the
second. Consequently the second invocation will fail to perform the
task_state check and therefore succeed, resulting in a race.

We rewrite the old race unit test which wasn't testing the correct
thing for 2 reasons:

1. Due to the bug fixed in this patch, although we were calling
   update_on_match() twice, the second call didn't check the task state.
2. side_effect=iterable returns function items without executing them,
   but we weren't hitting this due to the bug fixed in this patch.

Closes-Bug: #1821373
Change-Id: I01c63e685113bf30e687ccb14a4d18e344b306f6
(cherry picked from commit aae5c7aa38)
(cherry picked from commit 61fef49b15)
2019-05-20 11:57:01 +01:00
..
api_migrations Merge "Add queued for delete to instance_mappings table." 2018-07-11 21:32:30 +00:00
migrate_repo Add trusted_certs to instance_extra 2018-03-29 23:00:42 -04:00
__init__.py Remove SQLite BigInteger/Integer translation logic 2015-12-07 12:49:22 -05:00
api.py Fix retry of instance_update_and_get_original 2019-05-20 11:57:01 +01:00
api_models.py Online data migration for queued_for_delete flag 2018-07-23 14:48:18 -07:00
migration.py Isolate placement database config 2018-06-19 13:22:04 +01:00
models.py Add trusted_certs to instance_extra 2018-03-29 23:00:42 -04:00
types.py Use is_valid_cidr and is_valid_ipv6_cidr from oslo_utils 2017-01-31 11:45:00 +00:00
utils.py Remove translation of log messages 2017-07-18 09:03:39 +00:00