fix: keep VectorDB health probes responsive - #2617
Conversation
Signed-off-by: Kyle Zheng <kyzheng@nvidia.com>
Greptile SummaryThe PR separates shallow VectorDB liveness from storage-aware readiness and moves backend inspection off the asyncio event loop.
|
| Filename | Overview |
|---|---|
| nemo_retriever/src/nemo_retriever/service/vectordb_app.py | Adds shallow liveness and offloads backend inspection, but the previously reported synchronization defect remains in the shared backend path. |
| nemo_retriever/src/nemo_retriever/common/vdb/lancedb_collections.py | Optimizes recovery health scans and adds an index, while collection health still accesses table state outside the mutation lock. |
| nemo_retriever/src/nemo_retriever/common/vdb/adt_vdb.py | Documents the new concurrency expectation for backend implementations without enforcing it. |
| nemo_retriever/helm/templates/deployment-vectordb.yaml | Correctly moves startup and liveness probes to the shallow endpoint while preserving readiness on /v1/health. |
| nemo_retriever/tests/test_service_vectordb_app.py | Verifies liveness responsiveness during blocked health inspection but does not exercise overlapping real LanceDB health and mutation operations. |
| nemo_retriever/tests/test_lancedb_collections.py | Covers filtered health scans and additive recovery-state index creation for existing catalogs. |
Sequence Diagram
sequenceDiagram
participant K as Kubernetes
participant A as VectorDB API
participant T as Worker thread
participant L as LanceDB
K->>A: GET /v1/live
A-->>K: "200 {"status":"ok"}"
K->>A: GET /v1/health
A->>T: Offload backend health
T->>L: Inspect catalog and storage
L-->>T: Health details
T-->>A: Backend health
A-->>K: 200 or 503
Reviews (2): Last reviewed commit: "docs: clarify VectorDB health contracts" | Re-trigger Greptile
| async def health() -> dict[str, Any]: | ||
| current = state | ||
| backend_health = _safe_backend_health(current) | ||
| backend_health = await asyncio.to_thread(_safe_backend_health, current) |
There was a problem hiding this comment.
Unsynchronized backend health inspection
If health, metrics, reconciliation, writes, or queries overlap, asyncio.to_thread accesses the same stateful VectorDB instance from multiple threads without the query semaphore or collection-store write lock, exposing shared LanceDB handles, cache state, and health counters to inconsistent results or backend errors. Serialize these inspections or explicitly establish and document the backend's thread-safety contract.
Rule Used: Models and stateful components accessed from Ray a... (source)
Knowledge Base Used: Service observability and integrations
Prompt To Fix With AI
This is a comment left during a code review.
Path: nemo_retriever/src/nemo_retriever/service/vectordb_app.py
Line: 456
Comment:
**Unsynchronized backend health inspection**
If health, metrics, reconciliation, writes, or queries overlap, `asyncio.to_thread` accesses the same stateful VectorDB instance from multiple threads without the query semaphore or collection-store write lock, exposing shared LanceDB handles, cache state, and health counters to inconsistent results or backend errors. Serialize these inspections or explicitly establish and document the backend's thread-safety contract.
**Rule Used:** Models and stateful components accessed from Ray a... ([source](https://github.com/nvidia/nemo-retriever/blob/ee27a78852a4643a1bddf318679184ab92a41684/nemo_retriever/.greptile/config.json))
**Knowledge Base Used:** [Service observability and integrations](https://app.greptile.com/nvidia-public-github/-/custom-context/knowledge-base/nvidia/nemo-retriever/-/docs/service-observability-and-integrations.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Signed-off-by: Kyle Zheng <kyzheng@nvidia.com>
Description
Keep the VectorDB service responsive when LanceDB health inspection is slow or the document catalog is large.
This change:
GET /v1/liveendpoint that performs no backend or storage operations.recovery_state != ''.recovery_statefor existing and new catalogs./v1/livefor VectorDB startup and liveness probes while retaining/v1/healthfor readiness.The existing
/v1/healthresponse contract and status codes remain unchanged. This does not change ingestion, retrieval, ranking, identifiers, collection behavior, or stored document data, and it requires no data migration.Validation
/v1/live,/v1/health, and/v1/collections.Checklist