[openstack-dev] [Cinder] Question about synchronized decoration usage in cinder-volume

Vishvananda Ishaya vishvananda at gmail.com
Tue May 6 16:35:21 UTC 2014


On Apr 26, 2014, at 2:56 AM, Zhangleiqiang (Trump) <zhangleiqiang at huawei.com> wrote:

> Hi, all:
> 
> 	I find almost all of the @utils.synchronized decoration usage in cinder-volume (cinder.volume.manager / cinder.volume.drivers.*) with an "external=True" param. Such as cinder.volume.manager.VolumeManager:attach_volume:
> 
> 	    def attach_volume(self, context, volume_id, instance_uuid, host_name,
>                      mountpoint, mode):
>        """Updates db to show volume is attached."""
>        @utils.synchronized(volume_id, external=True)
>        def do_attach():
> 
> 	However, in docstring of common.lockutils.synchronized, I find param "external" is used for multi-workers scenario:
> 	
> 		:param external: The external keyword argument denotes whether this lock
>    	should work across multiple processes. This means that if two different
>    	workers both run a a method decorated with @synchronized('mylock',
>    	external=True), only one of them will execute at a time.
> 	
> 	I have two questions about it.
> 	1. As far as I know, cinder-api has supported multi-worker mode and cinder-volume doesn't support it, does it? So I wonder why the "external=True" param is used here?

Before the multibackend support in cinder-volume it was common to run more than one cinder-volume for different backends on the same host. This would require external=True
> 	2. Specific to cinder.volume.manager.VolumeManager:attach_volume, all operations in "do_attach" method are database related. As said in [1], operations to the database will block the main thread of a service, so another question I want to know is why this method is needed to be synchronized?
Currently db operations block the main thread of the service, but hopefully this will change in the future.

Vish

> 
> 	Thanks.
> 
> [1] http://docs.openstack.org/developer/cinder/devref/threading.html#mysql-access-and-eventlet
> ----------
> zhangleiqiang (Trump)
> 
> Best Regards
> 
> 
> 
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140506/6765ae11/attachment.pgp>


More information about the OpenStack-dev mailing list