summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGorka Eguileor <geguileo@redhat.com>2020-02-27 14:04:13 +0100
committerDavid Hill <davidchill@hotmail.com>2020-03-23 13:10:35 +0000
commit614f48d61c8db10d7ee328ad92612fd15f0671d7 (patch)
treeb018f1edbd8bef52d999ad2f3463525d9c7a04b7
parent121515cf596ead8fbe9a4c3967bf1eacf975e738 (diff)
downloadcinder-614f48d61c8db10d7ee328ad92612fd15f0671d7.tar.gz
ChunkedBackupDriver: Freeing memory on restore
When restoring many backups, the backup service uses a lot of memory and when we do many concurrent restores the backup service ends up getting killed becase the system runs out of memory. This patch reduces the ref count to the data as soon as possible to let Python garbage collect it instead of hogging it for the whole chunk restore. Related-Bug: #1865011 Change-Id: I942d9d8b3976232ae1cf82b698fb27285fbef13a (cherry picked from commit 69462315bc8416bd02ebd6085f0cfc141cfd8877) (cherry picked from commit 94db15dd3b86c7da92ceaa4b8c2d948b2b30c65b) (cherry picked from commit f4aa81424fff8718bd432cc5a7aae357fe028023) (cherry picked from commit 20b6b7477daae43907f38337aef15a5f47a92283)
-rw-r--r--cinder/backup/chunkeddriver.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/cinder/backup/chunkeddriver.py b/cinder/backup/chunkeddriver.py
index d64bce106..fea570226 100644
--- a/cinder/backup/chunkeddriver.py
+++ b/cinder/backup/chunkeddriver.py
@@ -667,9 +667,12 @@ class ChunkedBackupDriver(driver.BackupDriver):
LOG.debug('decompressing data using %s algorithm',
compression_algorithm)
decompressed = decompressor.decompress(body)
+ body = None # Allow Python to free it
volume_file.write(decompressed)
+ decompressed = None # Allow Python to free it
else:
volume_file.write(body)
+ body = None # Allow Python to free it
# force flush every write to avoid long blocking write on close
volume_file.flush()