The function google_geocode_location() in geocoding/google.inc currently returns NULL if Google's geocoding server returns any type of error.

Error code 620 usually indicates that the user "has submitted too many [geocoding] requests in too short a period of time" (http://code.google.com/apis/maps/documentation/reference.html#GGeoStatus...). In my experience, the Google servers issue this code if they receive more than a few (1 to 5?) requests per second from a given site. It's easy for a popular site to exceed Google's velocity threshold, and even easier in the case of bulk import operations that invoke node_save(). Retrying the operation after a one second wait will usually succeed.

So this is a fairly common "soft" error that's easily rectified by retrying the operation. Unfortunately the functions that invoke google_geocode_location() (notably including node_save()) treat this as an unrecoverable condition and lat/long values of 0.0000 are stored in the Location node. This obviously causes problems for users and developers for which there's no recourse at this time.

I suggest adding a configuration parameter to the Location module's Geocoding options (admin/settings/location/geocoding), specifying the number of times to retry a 620 error, with an implied one-second sleep between tries. The default value for this retry parameter should be zero so as not to alter the behavior of existing installations. An upper limit of, say, 30 is probably also in order.

Note: Other Drupalers have alluded to this problem but not written it up explicitly. See: http://drupal.org/node/301275#comment-2153602 and http://drupal.org/node/317159#comment-2145356.

CommentFileSizeAuthor
#5 geocoding-delay-697468-5.patch1.36 KBjoelstein

Comments

sethcohn’s picture

+1

havran’s picture

+1

TimelessDomain’s picture

7.x is giving me this error in my log "Google geocoding returned status code: 620." It is failing to geocode every time. (EDIT: switched to yahoo for geocoding since google was not working - yahoo works)

bryancasler’s picture

Version: 6.x-3.0 » 6.x-3.x-dev

Same problem with D7

joelstein’s picture

Title: google_geocode_location() should retry "620" errors (G_GEO_TOO_MANY_QUERIES) » Add configurable delay for Google geocoding to avoid 620 errors
Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new1.36 KB

The following patch adds an option to configure how many milliseconds of delay should be injected in-between geocoding requests. 200ms seems to keep my site under the rate limits (no more than 5 requests per second). It defaults to 0 (no delay).

dmcgowen’s picture

We added the patch to our site and is keeping us under the geocoding limits imposed by Google.

dmcgowen’s picture

Status: Needs review » Reviewed & tested by the community

oops, forgot to change status....
We added the patch to our site and is keeping us under the geocoding limits imposed by Google.

EvanDonovan’s picture

After this gets in to 7.x, I will try to backport to 6.x, if it hasn't already been. I've experienced this as well, especially on batch ops.

Macronomicus’s picture

+1
Oh yea... that's exactly whats required for batch ops.
Cheers!

ankur’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch.

Committed to the 7.x-3.x and 7.x-5.x branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.