data/climate: fix geocode_nominatim's NameError on every call (P0, live) #51
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Jinemi/thermograph#51
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/geocode-nominatim-revgeo-lock"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
geocode_nominatimreferenced_REVGEO_LOCK, which no longer exists — it was removed when reverse geocoding moved from a bare lock to the dedicated worker/queue design, and the forward-geocode function was never updated to match. Every call raisedNameError, surfacing as a 502 on/geocode's Nominatim-fallback path. This has been live on prod, beta, dev, main, and release for ~30 hours — found during a post-hoc audit of the recent Open-Meteo-exit/ERA5-lake/daemon batch, not by a report.Blast radius: bare city names in the local GeoNames index still worked (so smoke checks passed), but every comma-qualified name ("Durham, NC"), postcode, neighbourhood, sub-1000-population village, or genuine local-index miss 502'd. Prod logs show real SSR traffic hitting this (
Nørrebro,Shimokitazawa,SW1A 1AA). The three existing tests covering this path all monkeypatchgeocode_nominatimitself, so none of them ever executed the broken body — 365 green tests, 100%-broken production path.Fix
Routes forward-geocode jobs through the same worker/queue that already serializes reverse-geocode jobs, instead of reintroducing a second lock. Both job kinds are now drained by the one worker thread, so
_revgeo_laststill has exactly one writer (no lock needed — same invariant as before) and the shared ~1/sec Nominatim pacing the docstring always claimed is now actually enforced.Deliberately not the naive fix (
_REVGEO_LOCK = threading.Lock()): the worker mutates_revgeo_lastwith no lock by design (single-writer), so a second uncoordinated pacer would race it and could violate the documented Nominatim ≤1 req/s policy.Tests
geocode_nominatim), matching the existing reverse-geocode test style._requestto run_fetch_geocode_forward's actual body — the function whose earlier version never once executed successfully in production.duckdbpackage in this local venv, nothing to do with geocoding).Deploy
Targeting
devfirst for a beta smoke-test, then promoting tomain/releasepromptly given severity.