lib/dumper/job.rb in dumper-1.4.2 vs lib/dumper/job.rb in dumper-1.4.3
- old
+ new
@@ -86,14 +86,24 @@
def upload_by_aws_sdk(json)
log "uploading by aws-sdk v#{AWS::VERSION}"
s3 = json[:s3_federation]
aws = AWS::S3.new(s3[:credentials])
- aws.buckets[s3[:bucket]].objects[s3[:key]].write(
- file: @database.dump_path,
- content_type: 'application/octet-stream',
- content_disposition: "attachment; filename=#{@database.filename}",
- )
+
+ retry_count = 0
+ begin
+ aws.buckets[s3[:bucket]].objects[s3[:key]].write(
+ file: @database.dump_path,
+ content_type: 'application/octet-stream',
+ content_disposition: "attachment; filename=#{@database.filename}",
+ )
+ rescue # Errno::ECONNRESET, Errno::EPIPE, etc.
+ raise if retry_count > 8
+ retry_count += 1
+ log "upload failed: #{$!} - retrying after #{2 ** retry_count}sec..."
+ sleep 2 ** retry_count
+ retry
+ end
end
def upload_by_multipart_post(json)
require 'net/http/post/multipart'
log "uploading by multipart-post v#{Gem.loaded_specs['multipart-post'].version.to_s}"