Quoting one old comment:
There are several places where in the future we might consider adding DBlock_hostids(). For example in DBdelete_hosts_with_prototypes() while we are busy deleting host prototypes another action may link a template with more host prototypes. Similarly in DBdelete_host_prototypes() while we are deleting discovered hosts LLD may occur and add more discovered hosts. Currently in lld_hosts_save() we don't check whether parent host prototype id is locked for deletion like we do in lld_graphs_save(), lld_items_save() and lld_triggers_save().