0
votes

I am uploading the file to Google Drive with resumable/simple upload, depending upon the file size. I am facing issue while uploading google document files with 500 Internal Server Error. As Google documents suggest to use Exponential Backup for this error. I trying to upload the same data after some time interval (after one minute) >But it give error as 410 Gone

My findings for this issue is ...

  1. While creating file on drive set mime type of file as application/octet-stream or keep its value null
  2. upload the data using resumable/ simple upload
  3. Receive success result but the file has appeared as a zip file instead of Google document file.
  4. if I set mime type while creating file provided by Google, the document file is created.
  5. But while uploading data it throws error (500 and 410)

What could be the possible solution for this issue?

1
Can you paste your code. Does a given file fail (a) always, or (b) sometimes? - pinoyyid
Yes. the given file fails always - Mayuresh
then you can probably forget about exponential backoff. Unfortunately the 500 status covers a myriad of situations, not all of which are recoverable. Try reducing the amount of work you're asking Drive to do, eg smaller chunk sizes - pinoyyid

1 Answers

1
votes

500 Internal Server Error

Basically means that the server processing your request is busy. You are not the only developer accessing said server so if someone else made a very processor heavy request at the same time you sent your request well your request may timeout. As you mentioned google says we should implement exponential backoff in the case of 5xx errors.

The 410 response is primarily intended to assist the task of web maintenance by notifying the recipient that the resource is intentionally unavailable and that the server owners desire that remote links to that resource be removed. Such an event is common for limited-time, promotional services and for resources belonging to individuals no longer associated with the origin server's site. It is not necessary to mark all permanently unavailable resources as "gone" or to keep the mark for any length of time -- that is left to the discretion of the server owner.

This means that you waited to long before resending your request.

Implementing Exponential backoff.

Exponential backoff is the process of a client periodically retrying a failed request over an increasing amount of time. It is a standard error handling strategy for network applications. The Core Reporting API is designed with the expectation that clients which choose to retry failed requests do so using exponential backoff. Besides being "required", using exponential backoff increases the efficiency of bandwidth usage, reduces the number of requests required to get a successful response, and maximizes the throughput of requests in concurrent environments.

The flow for implementing simple exponential backoff is as follows.

  1. Make a request to the API
  2. Receive an error response that has a retry-able error code
  3. Wait 1s + random_number_milliseconds seconds
  4. Retry request
  5. Receive an error response that has a retry-able error code
  6. Wait 2s + random_number_milliseconds seconds
  7. Retry request
  8. Receive an error response that has a retry-able error code
  9. Wait 4s + random_number_milliseconds seconds
  10. Retry request
  11. Receive an error response that has a retry-able error code
  12. Wait 8s + random_number_milliseconds seconds
  13. Retry request
  14. Receive an error response that has a retry-able error code
  15. Wait 16s + random_number_milliseconds seconds
  16. Retry request
  17. If you still get an error, stop and log the error.

In the above flow, random_number_milliseconds is a random number of 1. milliseconds less than or equal to 1000. This is necessary to avoid certain lock errors in some concurrent implementations. random_number_milliseconds must be redefined after each wait.

Answer: There is no way to avoid the 500 errors you will get them from time to time. I think your issue is that yous say you are waiting after one minute to send your request that is why you are getting the 410 errors.

Note: I have logged a bug report requesting that the give a better example of Implementing Exponential Backoff for Google drive