apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[Bug]: Nearby sends 20 Wikidata queries at once and gets "Rate limit exceeded" (429) when loading a busy area

Open Medhansh-741 opened this issue 1 week ago • 2 comments

Summary

When Nearby loads place details it runs 20 requests to the Wikidata Query Service at the same time, 10 places each (CONNECTION_COUNT = 20). WDQS allows 5 parallel queries per client (query limits), so loading a busy area with nothing cached gets some requests rejected with HTTP 429 "Rate limit exceeded".

When a request fails, each of its 10 places is requested again on its own, all at once. After a 429 that means 10 more requests right after being told to slow down. If a single request also fails, that place keeps its incomplete data.

The requests use OkHttp's synchronous execute(), so OkHttp's own limit of 5 requests per host doesn't apply (it only covers enqueue()).

Steps to reproduce

  1. Open Nearby in a busy area with nothing cached. I used central Paris (48.86, 2.34).
  2. Press Refresh, which clears the place cache and loads the details of every pin again.
  3. Look at logcat for OkHttp answers from query.wikidata.org and the NearbyPinDetails tag.

Expected behaviour

The details load without being rate limited. If WDQS still answers 429, the app waits and tries again instead of sending more requests at once.

Actual behaviour

One Refresh sent 120 requests in about 6.5 seconds, 20 of them in the first second. 118 got 200 and 2 got 429. The 100 normal requests are the 1000 places in batches of 10, the other 20 are the two rejected batches sent again one place at a time.

The 429 answers had no Retry-After header, only the text "Rate limit exceeded".

When I only panned around the same area, details came from the cache (39 requests over 5 pans, all 200), so this shows up when a busy area loads with nothing cached: first visit, after Refresh, or after the cache expires.

Device name

OnePlus CPH2491

Android version

Android 16, stock OxygenOS (CPH2491_16.0.5.1301)

Commons app version

main at 99bb33d, betaDebug. The only local change was setting the HTTP logging to BASIC in NetworkingModule.kt, because at BODY level this phone drops most of the app's log lines.

Device logs

11-23 17:25:04.439 OkHttp  : <-- 429 https://query.wikidata.org/sparql?... (381ms, 20-byte body)
11-23 17:25:04.441 NearbyPinDetails: java.io.IOException: Unexpected response code: 429
11-23 17:25:05.202 OkHttp  : <-- 429 https://query.wikidata.org/sparql?... (377ms, 20-byte body)
11-23 17:25:05.203 NearbyPinDetails: java.io.IOException: Unexpected response code: 429

Screenshots

No response

Would you like to work on the issue?

Yes

Medhansh-741 avatar Nov 23 '26 12:11 Medhansh-741

Assigned to you, @Medhansh-741! Thanks!

nicolas-raoul avatar Nov 23 '26 12:11 nicolas-raoul

@nicolas-raoul opened #7414 for this. Failed batches aren't split anymore and a 429 pauses all detail requests and retries the batch once; I kept 20 parallel requests since 3 or 5 made loading several times slower on my phone, the numbers are in the PR.

Medhansh-741 avatar Nov 23 '26 19:11 Medhansh-741