Skip to content

Fix upload stall error introduced with S3 throttle #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions mongodb_consistent_backup/Upload/S3/S3UploadThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ def run(self):
break
try:
if self.multipart_id and self.multipart_num and self.multipart_parts:
mp_log_info = "s3://%s%s (multipart: %d/%d, size: %.2fmb)" % (
self.bucket_name, self.short_key_name(self.key_name), self.multipart_num,
self.multipart_parts, float(self.byte_count / 1024.00 / 1024.00))
for mp in self.bucket.get_all_multipart_uploads():
if mp.id == self.multipart_id:
logging.info("Uploading AWS S3 key: s3://%s%s (multipart: %d/%d, size: %.2fmb)" % (
self.bucket_name,
self.short_key_name(self.key_name),
self.multipart_num,
self.multipart_parts,
float(self.byte_count / 1024.00 / 1024.00)
))
logging.info("Uploading AWS S3 key: %s" % mp_log_info)
callback_count = 10
if self.target_bandwidth is not None:
# request a callback every 2MB to allow for somewhat decent throttling
callback_count = self.byte_count / 1024 / 1024 / 2
# request a callback every 0.5MB to allow for somewhat decent throttling
callback_count = self.byte_count / 1024 / 1024 / 0.5
with FileChunkIO(self.file_name, 'r', offset=self.multipart_offset, bytes=self.byte_count) as fp:
mp.upload_part_from_file(fp=fp, cb=self.status, num_cb=callback_count, part_num=self.multipart_num)
break
break
else:
raise OperationError("Missing multipart upload id %s for %s in S3 response." %
(self.multipart_id, mp_log_info))
else:
key = None
try:
Expand All @@ -143,8 +143,8 @@ def run(self):
key = Key(bucket=self.bucket, name=self.key_name)
callback_count = 10
if self.target_bandwidth is not None:
# request a callback every 2MB to allow for somewhat decent throttling
callback_count = self.byte_count / 1024 / 1024 / 2
# request a callback every 0.5MB to allow for somewhat decent throttling
callback_count = self.byte_count / 1024.00 / 1024.00 / 0.5
key.set_contents_from_filename(self.file_name, cb=self.status, num_cb=callback_count)
finally:
if key:
Expand Down