Uploading files to S3 from EC2 instances fails on some instance types
We have a very strange problem. We are uploading large (10M) files from an EC2 instance to an S3 bucket in the same region. We use aws s3 cp for the upload and instance roles for authentication.
If we use an m1.small EC2 instance the upload works fine. But if we increase the instance size (we have tried m1.large and m3.large) the upload fails.
Here is the error we get:
upload failed: <file> to <s3-address>
HTTPSConnectionPool(host='<bucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: <s2-key>?partNumber=2&uploadId=Hw6FZhXeH03ZzzCtxu2XcsspmpN2lx83GxWGzrJ96I81XlajjjNCxsSj0vs0BIbf_xJmzfdZwZY_UzUL3NCT57rpqEwIuLD1qryr7KKjlR6rA0YIW_ltopZQkoo32i0qTPUAlBc55WRAYxjwJ8Iw1A-- (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
This is completely reproducible -- we have never had such a upload succeed after tens of attempts. We have never seen the problem on an m1.small instance in hundreds of attempts.
We ran into this problem with 10M files. We have found that it is reproducible down to about 1M. Much less than this and it works fine every time.
Any ideas about what is going on would be much appreciated.
What version of the CLI are you using? This looks like https://github.com/aws/aws-cli/pull/594, which was fixed in 1.2.11
Actually, that issue was for downloads, this one is for uploads so it's likely a different issue. I'll need to look into this further. If you could provide a --debug log of this, it would help in troubleshooting.
Also approximately how many 10M files are you uploading at once?
I'm also having issues uploading to s3, but from my laptop (OSX mavericks). A 424KB file failed, and a 344KB file worked. I'm uploading one file at a time, with the following versions:
awscli==1.2.13
boto==2.24.0
botocore==0.33.0
The error is the same as the original post:
upload failed: ./test to s3://<bucket>/deploys/test HTTPSConnectionPool(host='bnch.s3.amazonaws.com', port=443): Max retries exceeded with url: /deploys/test (Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
I ran it with --debug, and here's the part that keeps on retrying:
2014-02-06 21:20:17,138 - botocore.retryhandler - DEBUG - Retry needed, action of: 3.28890874908
2014-02-06 21:20:17,138 - botocore.endpoint - DEBUG - Response received to retry, sleeping for 3.28890874908 seconds
2014-02-06 21:20:20,428 - botocore.awsrequest - DEBUG - Rewinding stream: <open file u'<redacted>/test', mode 'rb' at 0x101dc6c90>
2014-02-06 21:20:20,428 - botocore.endpoint - DEBUG - Sending http request: <PreparedRequest [PUT]>
2014-02-06 21:20:20,429 - botocore.vendored.requests.packages.urllib3.connectionpool - INFO - Starting new HTTPS connection (4): <bucket>.s3.amazonaws.com
2014-02-06 21:20:21,693 - botocore.hooks - DEBUG - Event needs-retry.s3.PutObject: calling handler <botocore.retryhandler.RetryHandler object at 0x101e0d550>
2014-02-06 21:20:21,693 - botocore.retryhandler - DEBUG - retry needed, retryable exception caught: HTTPSConnectionPool(host='<bucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /deploys/test (Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
Traceback (most recent call last):
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 262, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 310, in __call__
caught_exception)
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 219, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 352, in _check_caught_exception
raise caught_exception
ConnectionError: HTTPSConnectionPool(host='<bucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /deploys/test (Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
2014-02-06 21:20:21,693 - botocore.retryhandler - DEBUG - Retry needed, action of: 2.598356941
2014-02-06 21:20:21,693 - botocore.endpoint - DEBUG - Response received to retry, sleeping for 2.598356941 seconds
2014-02-06 21:20:24,293 - botocore.awsrequest - DEBUG - Rewinding stream: <open file u'<redacted>/test', mode 'rb' at 0x101dc6c90>
2014-02-06 21:20:24,293 - botocore.endpoint - DEBUG - Sending http request: <PreparedRequest [PUT]>
2014-02-06 21:20:24,294 - botocore.vendored.requests.packages.urllib3.connectionpool - INFO - Starting new HTTPS connection (5): <bucket>.s3.amazonaws.com
2014-02-06 21:20:25,888 - botocore.hooks - DEBUG - Event needs-retry.s3.PutObject: calling handler <botocore.retryhandler.RetryHandler object at 0x101e0d550>
2014-02-06 21:20:25,888 - awscli.customizations.s3.tasks - DEBUG - <redacted>/test upload failure: HTTPSConnectionPool(host='<bucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /deploys/test (Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
2014-02-06 21:20:25,888 - botocore.operation - DEBUG - Operation:PutObject called with kwargs: {'body': <open file u'<redacted>/test', mode 'rb' at 0x101e61d20>, 'bucket': u'<bucket>', 'key': u'deploys/test'}
2014-02-06 21:20:25,889 - botocore.endpoint - DEBUG - Making request for Operation:PutObject (verify_ssl=True) with params: {'headers': {}, 'uri_params': {u'Bucket': u'<bucket>', u'Key': u'deploys/test'}, 'payload': <botocore.payload.Payload object at 0x101fc3ed0>}
2014-02-06 21:20:25,889 - botocore.endpoint - DEBUG - Building URI for rest endpoint.
2014-02-06 21:20:25,889 - botocore.endpoint - DEBUG - Templated URI path: /{Bucket}/{Key}
2014-02-06 21:20:25,889 - botocore.endpoint - DEBUG - Templated URI query_params:
2014-02-06 21:20:25,889 - botocore.endpoint - DEBUG - Rendered path: /<bucket>/deploys/test
2014-02-06 21:20:25,889 - botocore.endpoint - DEBUG - Rendered query_params:
2014-02-06 21:20:25,890 - botocore.hooks - DEBUG - Event before-auth.s3: calling handler <function fix_s3_host at 0x101b24410>
2014-02-06 21:20:25,890 - botocore.handlers - DEBUG - Checking for DNS compatible bucket for: https://s3-us-west-2.amazonaws.com/<bucket>/deploys/test
2014-02-06 21:20:25,890 - botocore.handlers - DEBUG - URI updated to: https://<bucket>.s3.amazonaws.com/deploys/test
2014-02-06 21:20:25,890 - botocore.auth - DEBUG - Calculating signature using hmacv1 auth.
2014-02-06 21:20:25,890 - botocore.auth - DEBUG - HTTP request method: PUT
2014-02-06 21:20:25,890 - botocore.auth - DEBUG - StringToSign:
PUT
Fri, 07 Feb 2014 05:20:25 GMT
/<bucket>/deploys/test
2014-02-06 21:20:25,891 - botocore.endpoint - DEBUG - Sending http request: <PreparedRequest [PUT]>
2014-02-06 21:20:25,891 - botocore.vendored.requests.packages.urllib3.connectionpool - INFO - Starting new HTTPS connection (6): <bucket>.s3.amazonaws.com
2014-02-06 21:20:27,373 - botocore.hooks - DEBUG - Event needs-retry.s3.PutObject: calling handler <botocore.retryhandler.RetryHandler object at 0x101e0d550>
2014-02-06 21:20:27,374 - botocore.retryhandler - DEBUG - retry needed, retryable exception caught: HTTPSConnectionPool(host='<bucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /deploys/test (Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
Traceback (most recent call last):
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 262, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 310, in __call__
caught_exception)
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 219, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "<redacted>/lib/python2.7/site-packages/botocore/retryhandler.py", line 352, in _check_caught_exception
raise caught_exception
ConnectionError: HTTPSConnectionPool(host='<bucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /deploys/test (Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
2014-02-06 21:20:27,374 - botocore.retryhandler - DEBUG - Retry needed, action of: 0.627294998584
2014-02-06 21:20:27,374 - botocore.endpoint - DEBUG - Response received to retry, sleeping for 0.627294998584 seconds
We are using version 1.2.13. We have about 200 of these files to upload, but we are doing it in series. The problem always happens on the first one.
Here is the debug log of the failure that you asked for: https://gist.github.com/benbc/8861033.
Is there any update on this issue. I'm seeing Exactly the same issue trying to upload to a newly created bucket.
Yes I believe this should be fixed now in version 1.3.0. The root cause I believe is the same as https://github.com/aws/aws-cli/issues/544.
Can you please try with the latest CLI version. If you're still seeing the issue, please attach a --debug logs and I'll repoen the issue.
i'm still having this issue upload to s3, neither from my laptop ,nor from debian server .The file is about 100MB. I'm uploading one file at a time, with the following versions:
aws-cli/1.3.1 Python/2.7.3 Linux/3.2.0-4-amd64
aws-cli/1.3.1 Python/2.7.5 Darwin/13.0.0
Here is the issue I get:
Max retries exceeded with url: <myfile>?partNumber=13&uploadId=bR1a29GdR1Qb0CW4fSDv9Vvi4PKJLF3eizWErF1SGvuMxUAh4vmHLmVQ7XjVSsFGmQi0N1U8KX5dR1uukEAMaAS8JxoQA89nJN2FFmQu2MRzIlrIzeMr4re5Zwvn3Hvv.n9IKm.OXOqy4NN87yohIA-- (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
Here is the debug log:
Wed, 19 Mar 2014 03:28:03 GMT
/<mybucket>/<myfile>?partNumber=9&uploadId=psq_ysXJSW9eplwLTW97ueGw1BMzG2qEXVoP9XiQsm06RP0_N_J_qPS1vZf4OOj0W33Bwdey2w4KNsbEltH_GIWO3jOQbcP64MEfTMd.OSUVsmZKsMIWCxZoqdbmspb1bD0YzAbG92F9R8pQQrXdkA--
2014-03-19 11:28:03,343 - botocore.endpoint - DEBUG - Sending http request: <PreparedRequest [PUT]>
partNumber=8&uploadId=psq_ysXJSW9eplwLTW97ueGw1BMzG2qEXVoP9XiQsm06RP0_N_J_qPS1vZf4OOj0W33Bwdey2w4KNsbEltH_GIWO3jOQbcP64MEfTMd.OSUVsmZKsMIWCxZoqdbmspb1bD0YzAbG92F9R8pQQrXdkA-- (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 262, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 310, in __call__
caught_exception)
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 219, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 352, in _check_caught_exception
raise caught_exception
ConnectionError: HTTPSConnectionPool(host='<mybucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /<myfile>?partNumber=8&uploadId=psq_ysXJSW9eplwLTW97ueGw1BMzG2qEXVoP9XiQsm06RP0_N_J_qPS1vZf4OOj0W33Bwdey2w4KNsbEltH_GIWO3jOQbcP64MEfTMd.OSUVsmZKsMIWCxZoqdbmspb1bD0YzAbG92F9R8pQQrXdkA-- (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
2014-03-19 11:28:05,374 - botocore.retryhandler - DEBUG - Retry needed, action of: 0.41042383996
2014-03-19 11:28:05,374 - botocore.endpoint - DEBUG - Response received to retry, sleeping for 0.41042383996 seconds
2014-03-19 11:28:05,579 - botocore.hooks - DEBUG - Event needs-retry.s3.UploadPart: calling handler <botocore.retryhandler.RetryHandler object at 0x308bfd0>
2014-03-19 11:28:05,580 - botocore.retryhandler - DEBUG - retry needed, retryable exception caught: HTTPSConnectionPool(host=<mybucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /<myfile>?partNumber=1&uploadId=psq_ysXJSW9eplwLTW97ueGw1BMzG2qEXVoP9XiQsm06RP0_N_J_qPS1vZf4OOj0W33Bwdey2w4KNsbEltH_GIWO3jOQbcP64MEfTMd.OSUVsmZKsMIWCxZoqdbmspb1bD0YzAbG92F9R8pQQrXdkA-- (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 262, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 310, in __call__
caught_exception)
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 219, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 352, in _check_caught_exception
raise caught_exception
ConnectionError: HTTPSConnectionPool(host='<mybucket>.s3.amazonaws.com', port=443): Max retries exceeded with url: /<myfile>?partNumber=1&uploadId=psq_ysXJSW9eplwLTW97ueGw1BMzG2qEXVoP9XiQsm06RP0_N_J_qPS1vZf4OOj0W33Bwdey2w4KNsbEltH_GIWO3jOQbcP64MEfTMd.OSUVsmZKsMIWCxZoqdbmspb1bD0YzAbG92F9R8pQQrXdkA-- (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
Still seeing this issue using aws cp and aws sync on a new bucket. Smaller files went through no problem, larger files reliably fail as described here and #544
aws --version
aws-cli/1.3.3 Python/2.7.5+ Linux/3.8.0-35-generic
>>> print botocore.__version__
>>> 0.37.0
upload failed: ./file.tar.gz to s3://mybucket/file.tar.gz
HTTPSConnectionPool(host='mybucket.s3.amazonaws.com', port=443): Max retries exceeded with url: /file.tar.gz?partNumber=... (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
curl https://mybucket.s3.amazonaws.com
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>TemporaryRedirect</Code><Message>Please re-send this request to the specified temporary endpoint. Continue to use the original request endpoint for future requests.</Message><RequestId>...</RequestId><Bucket>mybucket</Bucket><HostId>...</HostId><Endpoint>mybucket.s3-us-west-1.amazonaws.com</Endpoint></Error>
As others have reported, this is now working fine after the TemporaryRedirect code clears --
$ curl https://mybucket.s3.amazonaws.com
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>...</RequestId><HostId>...</HostId></Error>%
I'm still encountering this problem with version 1.3.4 on a new Ireland bucket.
ubuntu@ip-172-31-40-164:~$ aws --version
aws-cli/1.3.4 Python/2.7.5+ Linux/3.11.0-15-generic
Debug log: https://gist.github.com/anonymous/9814978
Same bug for me when using 'aws s3 sync' $ aws --version aws-cli/1.3.4 Python/2.7.3 Linux/3.2.0-57-virtual
My bucket is in ireland.
debug log: https://paste.buntux.org/?c511ef0a27305636#e1/B5RiyBuZq60LHmLNpZt59wz2zDyY2KVdjCM+mO7E=
edit: I tested on a bucket in "US Standard" region --> no problem edit2: new url for debug log https://paste.jeekajoo.eu/?c511ef0a27305636#e1/B5RiyBuZq60LHmLNpZt59wz2zDyY2KVdjCM+mO7E=
I'm reopening this issue. After debugging this I can confirm what others have said. This problem exists when trying to upload a large file to a newly created bucket that's not in the classic region.
From what I can tell the CLI is properly retrying requests and following 307 redirects. The problem, however, is that the CLI sends the entire request and then waits for a response. However, S3 will immediately send the 307 response before we've finished sending the body. Eventually it will just close the connection, and if we're still in the process of streaming the body, we will not see the response. Instead we get the ConnectionError as shown in the various debug logs above.
The normal way to address this would be to use the expect 100 continue header. However, the HTTP client we use (requests) does not support this. There might be a way to work around this, but I'll need to do some digging into the requests library to see the best way to fix this issue.
I'll update this issue when I know more.
Any news?
my tests show that even when the boto library is failing, the AWS CLI works fine. what is the AWS CLI doing differently?
I don't think that there's any ways to workaround with in the requests library. I think our best option (aside from writing our own HTTP client that supports expect 100 continue) is some specific workaround in the S3 code.
I've just hit this too. My file isn't large, just a few megabytes.
Getting this with a 323KB CSS file.
Working on a fix for this, will update when I have more info.
Getting same issue when uploading large file (3GB) into S3. Uploading small file is just fine.
upload failed: ../../tmp/anonymousAction.log.2014-05-12.tokyo1b-http-4-1.20140513T003001 to s3://between-data-analysis-temp/anonymousAction.log.2014-05-12.tokyo1b-http-4-1.20140513T003001
HTTPSConnectionPool(host='between-data-analysis-temp.s3.amazonaws.com', port=443): Max retries exceeded with url: /anonymousAction.log.2014-05-12.tokyo1b-http-4-1.20140513T003001?partNumber=6&uploadId=Wdj8309FlXToB8mXw6JHnz8Xf8f4ADIC2SiaM3a6foSDJXH9t7xLk2uFK_EgTtjMn.OyCWdTJjP9al3rgISEltpMwj9j77Irfjc5wqssG2zgnUKhXM2gEUU5QfAuH0kuJNg8deDipYvwBkE0r7k3Qw-- (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
...
My aws version; aws-cli/1.3.13 Python/2.7.3 Linux/3.2.0-61-virtual
I'm getting a similar issue intermittently (about 1 file in every 20, files are around 500MB) using the requests library directly as we're working through our specific storage API. This is uploading from an EC2 instance.
File "/data/opi/upload.py", line 174, in upload
response = requests.put(url, data=data, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.1.0-py2.7.egg/requests /api.py", line 99, in put
return request('put', url, data=data, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.1.0-py2.7.egg/requests /api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.1.0-py2.7.egg/requests /sessions.py", line 382, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.1.0-py2.7.egg/requests /sessions.py", line 485, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.1.0-py2.7.egg/requests /adapters.py", line 372, in send
raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='our-bucket.s3.amazonaws.com', port=443): Max retries exceeded with url: /folder/subfolder/filename?Signature=XXX&Expires=1401262800&AWSAccessKeyId=YYY -amz-acl=private (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)