Open octaviancorlade opened 4 years ago
It looks like a fix won't be until we see httr2
so for now we can revert back to the googleAuthR retry code via these options:
options(googleAuthR.tryAttempts = 3,
googleAuthR.HttrRetryTimes = 1)
Once those are set can we test to see if it helps the issue?
I'm not sure about other services that would use googleAuthR, some links mentioned in the httr issue suggest capping at 32 or 64 seconds for the cloud storage API, but for Google Analytics it should work with tryAttempts = 5
i.e. one requests plus 5 retries in exponential backoff.
That is documented here for v4 and here the same for v3
We used this now with tryAttempts = 5
and that helped with that error, have been tested since I opened this issue, we now have more often 503 errors but that's probably a different topic: before this, requests that returned 503 were retried until a quota error was raised, so we could not easily notice them.
As a note since it has been a bit unintuitive HttrRetryTimes
defines the total number of requests that httr performs, while tryAttempts
defines the number of retry times after the first one in case of errors.
Cool yes the 503 is related to the error that started the retries. I guess you need to use slow_fetch=TRUE and/or decrease the page size to avoid it. The options above can be set on a library basis on load so for googleAnalyticsR for example will set them to what you suggest above.
What goes wrong
Recently the Google Analytics Reporting API V4 started returning a lot of 503 errors for some views, for which it expects exponential backoff to be used as described here i.e. at each attempt to sleep for
2^attempt + random(0, pause_base)
seconds. As an example, at the 3rd retry this would be8 + random(0, 1)
seconds.Instead the
httr::RETRY
call does "randomly wait between0
andpause_base * 2 ^ attempt
seconds", which at the 3rd retry israndom(0, 8)
, always smaller than the sleep expected by the Google API. This results in errors of the formSession Info