aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

S3 - RequestTimeout during large files

Open lloydcotten opened this issue 13 years ago • 37 comments

I'm trying to upload a large file (9 GB) and getting a RequestTimeout error using aws s3 mv ...

I haven't fully tested it yet, but it seems like if I run the command over and over it will eventually work.

Here's the debug log from a failed attempt: https://s3.amazonaws.com/nimbus-public/s3_backup.log

I'll post back if I determine that retrying the command several times works or not.

aws version: aws-cli/1.1.2 Python/2.7.3 Windows/2008ServerR2

lloydcotten avatar Oct 11 '13 14:10 lloydcotten

After multiple retries the command does eventually work on these large files (7-11GB). But sometimes takes dozens of retries.

BTW, I'm running the command on an EC2 instance - shouldn't be any latency or network issues.

lloydcotten avatar Oct 11 '13 17:10 lloydcotten

Looking into this, I believe I know what's causing the issue.

jamesls avatar Oct 11 '13 17:10 jamesls

Note, I'm having similar reliability issues moving even larger files ~175Gb to S3. We've tried mv, sync, and copy with various results. We're running the following: aws s3 --version aws-cli/1.1.2 Python/2.6.6 Linux/2.6.32-358.el6.x86_64

Note this is a single (large) file. It's already compressed.

We often see: A client error (RequestTimeout) occurred: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.

Because of the large file size, retrying is extremely expensive. The larger the file size, the less luck we're having.

Is there a better tool that can be used linux command line for moving big data to S3?

dcg9381 avatar Oct 15 '13 22:10 dcg9381

Out of 4 attempts yesterday, only one of them was successful. 25% isn't a good enough success rate for us to depend on this for what we're trying to do.

Let me know if you need full logging.

Recent improvements with ver 1.1.2 include giving a valid non-zero return code when we fail, so at least we know that we've failed.

Here's the most recent tail of the output:

2013-10-16 18:05:42,755 - botocore.hooks - DEBUG - Event before-auth.s3: calling handler <function fix_s3_host at 0x2527668> 2013-10-16 18:05:42,755 - botocore.handlers - DEBUG - Checking for DNS compatible bucket for: https://s3.amazonaws.com/AWL-Backup/mysql/innobackup-mysql-2013-10-16.xbstream?uploadId=Y1fx18aYpHc91zTKCYJWrziFTDYGYIWmow80MSK28xrH9RX7ZzxKs61mHKB1opG7YNlIeiSr8fcsSVN5_LSn5j0wBQQfe1GizoFVhC4arAQRDWiGLt_6HNrFu02ej1au 2013-10-16 18:05:42,755 - botocore.handlers - DEBUG - Not changing URI, bucket is not DNS compatible: AWL-Backup 2013-10-16 18:05:42,755 - botocore.auth - DEBUG - Calculating signature using hmacv1 auth. 2013-10-16 18:05:42,755 - botocore.auth - DEBUG - HTTP request method: DELETE 2013-10-16 18:05:42,756 - botocore.auth - DEBUG - StringToSign: DELETE

Thu, 17 Oct 2013 00:05:42 GMT /AWL-Backup/mysql/innobackup-mysql-2013-10-16.xbstream?uploadId=Y1fx18aYpHc91zTKCYJWrziFTDYGYIWmow80MSK28xrH9RX7ZzxKs61mHKB1opG7YNlIeiSr8fcsSVN5_LSn5j0wBQQfe1GizoFVhC4arAQRDWiGLt_6HNrFu02ej1au 2013-10-16 18:05:42,756 - botocore.endpoint - DEBUG - Sending http request: 2013-10-16 18:05:43,448 - botocore.response - DEBUG - Response Body:

2013-10-16 18:05:43,448 - botocore.hooks - DEBUG - Event needs-retry.s3.AbortMultipartUpload: calling handler <botocore.retryhandler.RetryHandler object at 0x2906b10> 2013-10-16 18:05:43,448 - botocore.retryhandler - DEBUG - No retry needed. 2013-10-16 18:05:43,449 - botocore.hooks - DEBUG - Event after-call.s3.AbortMultipartUpload: calling handler <awscli.errorhandler.ErrorHandler object at 0x2873650> 2013-10-16 18:05:43,449 - awscli.errorhandler - DEBUG - HTTP Response Code: 204

At this point the exit and return $? = 1 (failure).

dcg9381 avatar Oct 17 '13 15:10 dcg9381

This should be fixed now. The issue was that the s3 side of the connection was closing the connection while we were uploading data. We detect this and automatically retry the request when this happens. However, we need to ensure that if the body is a file like object (which is the case when cp/mv/sync'ing to s3) that we properly reset the stream back to the beginning to ensure we send the entire body contents again.

jamesls avatar Oct 17 '13 17:10 jamesls

James, thanks. I assume the fix is deployed. We've got an overnight cron to retest. If it fails, I'll be back at it next week.

dcg9381 avatar Oct 17 '13 23:10 dcg9381

The fix is in our develop branch now. It will be incorporated into our next release soon.

garnaat avatar Oct 17 '13 23:10 garnaat

garnatt, what's the release schedule or where can I watch for it?

dcg9381 avatar Oct 18 '13 01:10 dcg9381

The 1.2.0 release, which contains this bug fix, is now out.

jamesls avatar Oct 18 '13 04:10 jamesls

Thank you!

dcg9381 avatar Oct 18 '13 06:10 dcg9381

Just got this error uploading a 6.6Gb file:

"A client error (RequestTimeout) occurred: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed."
[root@digital ~]# aws s3 --version
aws-cli/1.2.0 Python/2.6.6 Linux/2.6.32-358.6.1.el6.x86_64

Debug Ouput from 2nd Attempt:

2013-10-20 20:49:05,319 - awscli.customizations.s3.tasks - DEBUG - Part number 477 completed for filename: FILE.tar
2013-10-20 20:49:05,348 - awscli.customizations.s3.executer - DEBUG - Received print task: {'message': u'upload: ..FILE.tar to s3://FILE.tar', 'total_parts': 483, 'error': False}
2013-10-20 20:49:06,642 - botocore.response - DEBUG - Response Body:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>RequestTimeout</Code><Message>Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.</Message><RequestId>REQUEST_ID</RequestId><HostId>HOST_ID</HostId></Error>
2013-10-20 20:49:06,643 - botocore.hooks - DEBUG - Event needs-retry.s3.UploadPart: calling handler <botocore.retryhandler.RetryHandler object at 0x31844d0>
2013-10-20 20:49:06,643 - botocore.retryhandler - DEBUG - No retry needed.
2013-10-20 20:49:06,643 - botocore.hooks - DEBUG - Event after-call.s3.UploadPart: calling handler <awscli.errorhandler.ErrorHandler object at 0x2f4bdd0>
2013-10-20 20:49:06,643 - awscli.errorhandler - DEBUG - HTTP Response Code: 400
2013-10-20 20:49:06,644 - awscli.customizations.s3.tasks - DEBUG - Error during part upload: A client error (RequestTimeout) occurred: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/awscli/customizations/s3/tasks.py", line 148, in __call__
    self._filename.service, 'UploadPart', params)
  File "/usr/lib/python2.6/site-packages/awscli/customizations/s3/utils.py", line 115, in operate
    http_response, response_data = operation.call(**kwargs)
  File "/usr/lib/python2.6/site-packages/botocore/operation.py", line 82, in call
    parsed=response[1])
  File "/usr/lib/python2.6/site-packages/botocore/session.py", line 550, in emit
    return self._events.emit(event_name, **kwargs)
  File "/usr/lib/python2.6/site-packages/botocore/hooks.py", line 158, in emit
    response = handler(**kwargs)
  File "/usr/lib/python2.6/site-packages/awscli/errorhandler.py", line 50, in __call__
    raise ClientError(msg)
ClientError: A client error (RequestTimeout) occurred: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
2013-10-20 20:49:06,712 - awscli.customizations.s3.executer - DEBUG - Received print task: {'message': u'upload failed: ..FILE.tar to s3://FILE.tar\nA client error (RequestTimeout) occurred: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.', 'error': True}
upload failed: ..FILE.tar to s3://FILE.tar
A client error (RequestTimeout) occurred: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
2013-10-20 20:49:07,128 - botocore.response - DEBUG - Response Body:

2013-10-20 20:49:07,128 - botocore.hooks - DEBUG - Event needs-retry.s3.UploadPart: calling handler <botocore.retryhandler.RetryHandler object at 0x31844d0>
2013-10-20 20:49:07,128 - botocore.retryhandler - DEBUG - No retry needed.
2013-10-20 20:49:07,128 - botocore.hooks - DEBUG - Event after-call.s3.UploadPart: calling handler <awscli.errorhandler.ErrorHandler object at 0x2f4bdd0>
2013-10-20 20:49:07,128 - awscli.errorhandler - DEBUG - HTTP Response Code: 200
2013-10-20 20:49:07,129 - awscli.customizations.s3.tasks - DEBUG - Part number 478 completed for filename: FILE.tar
2013-10-20 20:49:07,149 - awscli.customizations.s3.executer - DEBUG - Error calling task: Upload has been cancelled.
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/awscli/customizations/s3/executer.py", line 104, in run
    function()
  File "/usr/lib/python2.6/site-packages/awscli/customizations/s3/tasks.py", line 339, in __call__
    parts = self._upload_context.wait_for_parts_to_finish()
  File "/usr/lib/python2.6/site-packages/awscli/customizations/s3/tasks.py", line 437, in wait_for_parts_to_finish
    raise UploadCancelledError("Upload has been cancelled.")
UploadCancelledError: Upload has been cancelled.
2013-10-20 20:49:07,177 - awscli.customizations.s3.executer - DEBUG - Received print task: {'message': u'upload: ..FILE.tar to s3://FILE.tar', 'total_parts': 483, 'error': False}
2013-10-20 20:49:08,119 - botocore.response - DEBUG - Response Body:

2013-10-20 20:49:08,119 - botocore.hooks - DEBUG - Event needs-retry.s3.UploadPart: calling handler <botocore.retryhandler.RetryHandler object at 0x31844d0>
2013-10-20 20:49:08,119 - botocore.retryhandler - DEBUG - No retry needed.
2013-10-20 20:49:08,120 - botocore.hooks - DEBUG - Event after-call.s3.UploadPart: calling handler <awscli.errorhandler.ErrorHandler object at 0x2f4bdd0>
2013-10-20 20:49:08,120 - awscli.errorhandler - DEBUG - HTTP Response Code: 200
2013-10-20 20:49:08,120 - awscli.customizations.s3.tasks - DEBUG - Part number 480 completed for filename: FILE.tar
2013-10-20 20:49:08,142 - awscli.customizations.s3.executer - DEBUG - Received print task: {'message': u'upload: ..FILE.tar to s3://FILE.tar', 'total_parts': 483, 'error': False}

hubertott avatar Oct 20 '13 11:10 hubertott

Could you check in the debug logs if there's a traceback that occurs earlier in the logs? Generally, we've seen that the RequestTimeoutError occurs because something earlier in the upload triggered a retry and we weren't properly resetting the IO streams on a retry attempt, but this should be fixed in 1.2.0. I'd like to see what caused the initial retry.

I'm also trying to reproduce this issue on v1.2.0. I'll update with what I find.

jamesls avatar Oct 21 '13 18:10 jamesls

For clarification I was using the --recursive option on a folder which contained two sub-folders with a file in each. I have just tried the upload again explicitly specifying the .tar file only and it went through fine.

I will retry the folder with the --recursive option to get the debug logs you have requested.

hubertott avatar Oct 22 '13 01:10 hubertott

so request time-out issue is not resolved yet? I am trying to upload big file by Rails carrierwave, and it also shoots Request-Timeout issue. And it is really critical issue.

Is there anyone who resolved this issue?

bravilli avatar Jan 10 '14 13:01 bravilli

I've largely given up on the AWSCLI over a home connection. The connectivity and retry logic isn't robust enough to make this a viable solution. We timeout, retry, and eventually fail on large upload requests.

dcg9381 avatar Jan 10 '14 14:01 dcg9381

seems to work flawlessly on 1.3.12 :+1:

on 1.2.1 got:

upload failed: ./bigzip.zip to s3://mybucket-test-s3/bigzip.zip
A client error (RequestTimeout) occurred: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
``
I see a 

Completed 170 of 185 part(s) with -169 file(s) remaining

that decreases with each error message.
This is a aws s3 cp command from a EC2 Instance in the same region the bigzip.zip is about 1.3GB in size.

---

jamesonjlee avatar May 23 '14 21:05 jamesonjlee

I am seeing the same issue with a large file. Getting Max retries exceeded with url (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer). There doesn't seem to be a way to

samlambert avatar May 28 '14 01:05 samlambert

Same problem here with

aws-cli/1.2.9 Python/3.4.0 Linux/3.13.0-29-generic

philippgerard avatar Sep 26 '14 15:09 philippgerard

Hi, I m getting this even for 2KB files through data power. However 1KB files works fine.

naren3k avatar Jul 22 '16 08:07 naren3k

Still appears to be a problem. Brand new Ubuntu VM, installed AWS CLI tools, aws-cli/1.10.1 Python/3.5.2 Linux/4.4.0-38-generic botocore/1.3.23

Once more I face the dreaded ConnectionResetError 104!

upload failed: 1.pdf to s3://mybucket/1.pdf ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
upload failed: 1.pdf to s3://mybucket/1.pdf ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
upload failed: 2.pdf to s3://mybucket/2.pdf ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
upload failed: 3.jpg to s3://mybucket/3.jpg ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

techdragon avatar Sep 30 '16 11:09 techdragon