fix(vessels): protect Hormuz VesselAPI rows from AISStream eviction #25
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/vesselapi-hormuz-eviction"
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
/api/vesselsstayed empty for the Hormuz bbox even though the VesselAPI poller was fetching 50 vessels per 2xx (logs:VesselAPI poll OK: 50 vessels (remaining=148, calls_today=3)).Root cause:
vessel_last_knownis a single in-memory store capped at_MAX_VESSELS(6000). AISStream's live US-coast feed crowds it past the cap, and theevict oldest seen_atpass reaps the Hormuz VesselAPI rows — they're only refreshed everyVESSELAPI_INTERVAL(~4.8h), so they always sort as the oldest and get evicted within seconds of landing.Fix
app/live_layers.pyupsert_vesseleviction now excludessrc=vesselapirows from eviction candidates (clamped to the available evictable rows), so the Hormuz blind-spot stays resident between polls. Stops short of disabling AISStream or partitioning the cap.Test
tests/test_vesselapi.pyaddstest_eviction_keeps_vesselapi_rows: fills the store past a shrunk_MAX_VESSELSwith AISStream rows plus the oldest-seen_atVesselAPI row, triggers an eviction, asserts the VesselAPI row survives.Full suite: 152 passed / 16 skipped.
Live verify (post-merge)
Expect ≥1
extra.src=vesselapipoint inside Hormuz.