-
Notifications
You must be signed in to change notification settings - Fork 0
Add database connection resilience to the indexer #34
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestrustPull requests that update rust codePull requests that update rust code
Description
Priority: P1
Source
Senior Architect Code Review (2026-04-03)
Problem
The Rust indexer uses a single tokio_postgres client connection with no reconnection logic or connection pooling. If the database connection drops (network blip, Cloud SQL restart, maintenance window), the indexer crashes and requires a full container restart.
The current code spawns the connection task and logs errors but does not attempt recovery:
tokio::spawn(async move {
if let Err(error) = connection.await {
eprintln!("postgres connection error: {error}");
}
});Affected Files
apps/indexer/src/main.rs(Databasestruct)
Recommendation
Replace the bare tokio_postgres client with a connection pool such as deadpool-postgres or bb8-postgres. These handle:
- Automatic reconnection on connection loss
- Connection health checking
- Configurable pool size for concurrent package pollers
- Graceful degradation during database outages
Alternatively, wrap the existing client in a reconnection loop that detects connection failures and re-establishes the connection before retrying.
Acceptance Criteria
- Indexer survives a temporary database outage without crashing
- Connection is re-established automatically after a drop
- Concurrent package pollers share a connection pool
- Connection pool size is configurable via environment variable
- Behavior is tested (at minimum, a reconnection scenario)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestrustPull requests that update rust codePull requests that update rust code