mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 06:56:00 -03:30
fixes inventory update deadlock
* all inventory updates continue to occur in parallel up to the point that they update the database with their results. * the "funnel" is achieved by using a global per-inventory postgres named lock
This commit is contained in:
@@ -41,6 +41,7 @@ from awx.main.utils import (
|
|||||||
from awx.main.utils.common import _get_ansible_version
|
from awx.main.utils.common import _get_ansible_version
|
||||||
from awx.main.signals import disable_activity_stream
|
from awx.main.signals import disable_activity_stream
|
||||||
from awx.main.constants import STANDARD_INVENTORY_UPDATE_ENV
|
from awx.main.constants import STANDARD_INVENTORY_UPDATE_ENV
|
||||||
|
from awx.main.utils.pglock import advisory_lock
|
||||||
|
|
||||||
logger = logging.getLogger('awx.main.commands.inventory_import')
|
logger = logging.getLogger('awx.main.commands.inventory_import')
|
||||||
|
|
||||||
@@ -870,20 +871,21 @@ class Command(BaseCommand):
|
|||||||
Load inventory from in-memory groups to the database, overwriting or
|
Load inventory from in-memory groups to the database, overwriting or
|
||||||
merging as appropriate.
|
merging as appropriate.
|
||||||
'''
|
'''
|
||||||
# FIXME: Attribute changes to superuser?
|
with advisory_lock('inventory_{}_update'.format(self.inventory.id)):
|
||||||
# Perform __in queries in batches (mainly for unit tests using SQLite).
|
# FIXME: Attribute changes to superuser?
|
||||||
self._batch_size = 500
|
# Perform __in queries in batches (mainly for unit tests using SQLite).
|
||||||
self._build_db_instance_id_map()
|
self._batch_size = 500
|
||||||
self._build_mem_instance_id_map()
|
self._build_db_instance_id_map()
|
||||||
if self.overwrite:
|
self._build_mem_instance_id_map()
|
||||||
self._delete_hosts()
|
if self.overwrite:
|
||||||
self._delete_groups()
|
self._delete_hosts()
|
||||||
self._delete_group_children_and_hosts()
|
self._delete_groups()
|
||||||
self._update_inventory()
|
self._delete_group_children_and_hosts()
|
||||||
self._create_update_groups()
|
self._update_inventory()
|
||||||
self._create_update_hosts()
|
self._create_update_groups()
|
||||||
self._create_update_group_children()
|
self._create_update_hosts()
|
||||||
self._create_update_group_hosts()
|
self._create_update_group_children()
|
||||||
|
self._create_update_group_hosts()
|
||||||
|
|
||||||
def remote_tower_license_compare(self, local_license_type):
|
def remote_tower_license_compare(self, local_license_type):
|
||||||
# this requires https://github.com/ansible/ansible/pull/52747
|
# this requires https://github.com/ansible/ansible/pull/52747
|
||||||
|
|||||||
Reference in New Issue
Block a user