Reviewed: https://review.openstack.org/558068 Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=e2924ba2379adc19e7ebd07ead8efd5e9c8e367d Submitter: Zuul Branch: master
commit e2924ba2379adc19e7ebd07ead8efd5e9c8e367d Author: Eric Fried <efr...@us.ibm.com> Date: Sat Mar 31 11:42:52 2018 -0500 Use an independent transaction for _trait_sync Provides a fix for the referenced bug by using an independent transaction for the _trait_sync method, meaning it gets committed right away regardless of what happens in the calling scope. Change-Id: Ie9731d0df8cf52acdc7a442316a35798a4fed4cb Closes-Bug: 1760322 ** Changed in: nova Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1760322 Title: Traits not synced if first retrieval fails Status in OpenStack Compute (nova): Fix Released Bug description: If the first trait you try to retrieve from placement doesn't exist, traits are not synced from os_traits into the database, so it winds up empty. try: rp_obj.Trait.get_by_name(self.ctx, 'CUSTOM_GOLD') except exception.TraitNotFound: pass rp_obj.Trait.get_by_name(self.ctx, os_traits.HW_CPU_X86_AVX2) # <== raises TraitNotFound I *think* what's happening is this: 1 @staticmethod 2 @db_api.api_context_manager.writer # trait sync can cause a write 3 def _get_by_name_from_db(context, name): 4 _ensure_trait_sync(context) 5 result = context.session.query(models.Trait).filter_by( 6 name=name).first() 7 if not result: 8 raise exception.TraitNotFound(names=name) 9 return result Line 4 "succeeds" and sets _TRAITS_SYNCED = True. But because line 8 raises, the transaction is rolled back. Database stays empty. Subsequent retrieval attempts see _TRAITS_SYNCED == True so don't try to resync. To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1760322/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : yahoo-eng-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp