In the first version I pushed, I left the skip logic outside the lock for that reason -- but I got convinced otherwise. I think you're right that it could be moved outside the lock as it was read from the database before the lock (object isn't refreshed) so I think maybe the lock isn't helping anything there.
Here's the patch which added the lock to _sync_power_states:
https:/ /review. openstack. org/#/c/ 103174/
In the first version I pushed, I left the skip logic outside the lock for that reason -- but I got convinced otherwise. I think you're right that it could be moved outside the lock as it was read from the database before the lock (object isn't refreshed) so I think maybe the lock isn't helping anything there.