From the code review on #484:
The metrics cache was changed from RwLock to Mutex to fix a TOCTOU race where concurrent Prometheus scrapes could redundantly hit the database. However, this serialises cache-hit reads too — each scrape waits for the previous one to release the lock, even when the cache is fresh.
For a Prometheus endpoint scraped at low frequency (default 15-60s) this is harmless. If scrape intervals are ever tightened, a double-checked pattern (try read first, acquire write only on miss) could recover concurrent reads while keeping single-flight on miss.
Low priority — the current trade-off is reasonable.
From the code review on #484:
The metrics cache was changed from
RwLocktoMutexto fix a TOCTOU race where concurrent Prometheus scrapes could redundantly hit the database. However, this serialises cache-hit reads too — each scrape waits for the previous one to release the lock, even when the cache is fresh.For a Prometheus endpoint scraped at low frequency (default 15-60s) this is harmless. If scrape intervals are ever tightened, a double-checked pattern (try read first, acquire write only on miss) could recover concurrent reads while keeping single-flight on miss.
Low priority — the current trade-off is reasonable.