Thanks for your detailed explanation.

> >     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.

There may be another reason here which is mentioned by DuncanT in IRC a few 
days ago. Cinder-backup will also call some methods (at least the 
"attach_volume) of manager, and since cinder-backup is a standalone process, 
"external=True" should be used here.

----------
zhangleiqiang (Trump)

Best Regards


> -----Original Message-----
> From: Vishvananda Ishaya [mailto:vishvana...@gmail.com]
> Sent: Wednesday, May 07, 2014 12:35 AM
> To: OpenStack Development Mailing List (not for usage questions)
> Subject: Re: [openstack-dev] [Cinder] Question about synchronized decoration
> usage in cinder-volume
> 
> 
> On Apr 26, 2014, at 2:56 AM, Zhangleiqiang (Trump)
> <zhangleiqi...@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-acc
> ess-and-eventlet
> > ----------
> > zhangleiqiang (Trump)
> >
> > Best Regards
> >
> >
> >
> > _______________________________________________
> > OpenStack-dev mailing list
> > OpenStack-dev@lists.openstack.org
> > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to