diff --git a/app/models/manager_refresh/inventory_collection.rb b/app/models/manager_refresh/inventory_collection.rb index af4a62fb600..8c5f320e966 100644 --- a/app/models/manager_refresh/inventory_collection.rb +++ b/app/models/manager_refresh/inventory_collection.rb @@ -454,6 +454,7 @@ def initialize(model_class: nil, manager_ref: nil, association: nil, parent: nil @loaded_references = Set.new @db_data_index = nil @data_collection_finalized = false + @all_references_loaded = false @created_records = [] @updated_records = [] @@ -980,6 +981,7 @@ def full_collection_for_comparison private + attr_accessor :all_references_loaded attr_writer :attributes_blacklist, :attributes_whitelist, :db_data_index # Returns array of records identities @@ -1004,7 +1006,7 @@ def record_identity(record) # @param manager_uuid [String] a manager_uuid of the InventoryObject we search in the local DB def find_in_db(manager_uuid) # Use the cached db_data_index only data_collection_finalized?, meaning no new reference can occur - if data_collection_finalized? && db_data_index + if data_collection_finalized? && db_data_index && all_references_loaded return db_data_index[manager_uuid] else return db_data_index[manager_uuid] if db_data_index && db_data_index[manager_uuid] @@ -1017,6 +1019,8 @@ def find_in_db(manager_uuid) # Load the rest of the references from the DB populate_db_data_index! + self.all_references_loaded = true if data_collection_finalized? + db_data_index[manager_uuid] end