Non Windows per service lock for Backup service
The introduction of multiple processes on the Backup service in commit66b1a0049a
broke the service in Windows. On commit1710839a43
this was fixed by removing the original usage of os.getpgrp and using a global lock for all backup services running on the host. This global lock introduces an unnecessary bottleneck on non Windows systems. This patch fixes this bottleneck on non Windows systems by going back to using a lock using the os.getpgrp method for non Windows systems and using a global lock for Windows systems. Related-Bug: #1781168 Change-Id: If7178695bf8ab751bcede14aa56d8becee60e17b
This commit is contained in:
parent
49507ea1c0
commit
6cfe4fb364
@ -96,6 +96,7 @@ MAPPING = {
|
||||
# driver when it imports google.auth
|
||||
'cinder.backup.drivers.google': 'cinder.backup.drivers.gcs',
|
||||
}
|
||||
SERVICE_PGRP = '' if os.name == 'nt' else os.getpgrp()
|
||||
|
||||
|
||||
# TODO(geguileo): Once Eventlet issue #432 gets fixed we can just tpool.execute
|
||||
@ -190,14 +191,16 @@ class BackupManager(manager.ThreadPoolManager):
|
||||
self.backup_rpcapi = backup_rpcapi.BackupAPI()
|
||||
self.volume_rpcapi = volume_rpcapi.VolumeAPI()
|
||||
|
||||
@utils.synchronized('cleanup_incomplete_backups',
|
||||
@utils.synchronized('cleanup_incomplete_backups_%s' % SERVICE_PGRP,
|
||||
external=True, delay=0.1)
|
||||
def _cleanup_incomplete_backup_operations(self, ctxt):
|
||||
# Only the first launched process should do the cleanup, the others
|
||||
# have waited on the lock for the first one to finish the cleanup and
|
||||
# can now continue with the start process.
|
||||
if self._process_number != 1:
|
||||
LOG.debug("Process #%s skips cleanup.", self._process_number)
|
||||
LOG.debug("Process #%s %sskips cleanup.",
|
||||
self._process_number,
|
||||
'(pgid=%s) ' % SERVICE_PGRP if SERVICE_PGRP else '')
|
||||
return
|
||||
|
||||
LOG.info("Cleaning up incomplete backup operations.")
|
||||
|
Loading…
Reference in New Issue
Block a user