Merge "db: retry on deadlocks while adding an instance"
This commit is contained in:
commit
c613b083a9
|
@ -1734,6 +1734,7 @@ def _check_instance_exists_in_project(context, instance_uuid):
|
|||
|
||||
|
||||
@require_context
|
||||
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
|
||||
@pick_context_manager_writer
|
||||
def instance_create(context, values):
|
||||
"""Create a new Instance record in the database.
|
||||
|
|
|
@ -2248,6 +2248,12 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||
instance = self.create_instance_with_args()
|
||||
self.assertTrue(uuidutils.is_uuid_like(instance['uuid']))
|
||||
|
||||
@mock.patch.object(db.sqlalchemy.api, 'security_group_ensure_default')
|
||||
def test_instance_create_with_deadlock_retry(self, mock_sg):
|
||||
mock_sg.side_effect = [db_exc.DBDeadlock(), None]
|
||||
instance = self.create_instance_with_args()
|
||||
self.assertTrue(uuidutils.is_uuid_like(instance['uuid']))
|
||||
|
||||
def test_instance_create_with_object_values(self):
|
||||
values = {
|
||||
'access_ip_v4': netaddr.IPAddress('1.2.3.4'),
|
||||
|
|
Loading…
Reference in New Issue