parent
43063272bb
commit
29b8905051
1 changed files with 13 additions and 3 deletions
|
@ -14,7 +14,7 @@ from swiftclient.client import Connection, ClientException
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
from random import SystemRandom
|
from random import SystemRandom
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from time import time
|
from time import time, sleep
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from util.registry import filelike
|
from util.registry import filelike
|
||||||
|
@ -293,8 +293,18 @@ class SwiftStorage(BaseStorage):
|
||||||
updated_metadata[_SEGMENTS_KEY].append(_PartUploadMetadata(segment_path, offset,
|
updated_metadata[_SEGMENTS_KEY].append(_PartUploadMetadata(segment_path, offset,
|
||||||
bytes_written))
|
bytes_written))
|
||||||
else:
|
else:
|
||||||
# Delete the empty segment.
|
# Try to delete the empty segment, as it is not needed. This will occasionally fail
|
||||||
self.remove(segment_path)
|
# due to Swift's eventual consistency, so we retry a few times and then just leave it be.
|
||||||
|
for remaining_retries in range(2, -1, -1):
|
||||||
|
try:
|
||||||
|
self.remove(segment_path)
|
||||||
|
except IOError:
|
||||||
|
if remaining_retries:
|
||||||
|
sleep(0.25)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Otherwise, ignore it.
|
||||||
|
break
|
||||||
|
|
||||||
return bytes_written, updated_metadata
|
return bytes_written, updated_metadata
|
||||||
|
|
||||||
|
|
Reference in a new issue