From 6cfe4fb364f47b8487c378cf891ff68c9b0cf01e Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 19 Jul 2018 10:32:22 +0200 Subject: [PATCH] Non Windows per service lock for Backup service The introduction of multiple processes on the Backup service in commit 66b1a0049ab78754a5e90c182b09ec501596458c broke the service in Windows. On commit 1710839a4336dea996910b0894d69d1075c5954c 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 --- cinder/backup/manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cinder/backup/manager.py b/cinder/backup/manager.py index f6e0f126e6e..1110cebdb76 100644 --- a/cinder/backup/manager.py +++ b/cinder/backup/manager.py @@ -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.")