Correctness: hero_db store uses blocking rusqlite in async context #109

Open
opened 2026-05-11 13:50:40 +00:00 by thabeta · 0 comments
Owner

Severity: Medium

Location

crates/hero_aibroker_lib/src/store/hero_db.rs

Finding

All SQLite operations use blocking rusqlite calls directly in async handlers:

rust\npub async fn increment_usage(...) -> Result<()> {\n let mut conn = self.conn.lock().unwrap(); // blocking\n conn.execute(...)?; // blocking\n}\n

Impact

  • Blocks tokio runtime threads during I/O\n- Under concurrent load, all threads may block on SQLite\n- Can cause the entire async runtime to stall

Recommendation

  • Use tokio::task::spawn_blocking for all SQLite operations\n- Or use sqlx with async SQLite support\n- Consider WAL mode for concurrent reads
## Severity: Medium ## Location `crates/hero_aibroker_lib/src/store/hero_db.rs` ## Finding All SQLite operations use blocking `rusqlite` calls directly in async handlers: ```rust\npub async fn increment_usage(...) -> Result<()> {\n let mut conn = self.conn.lock().unwrap(); // blocking\n conn.execute(...)?; // blocking\n}\n``` ## Impact - Blocks tokio runtime threads during I/O\n- Under concurrent load, all threads may block on SQLite\n- Can cause the entire async runtime to stall ## Recommendation - Use `tokio::task::spawn_blocking` for all SQLite operations\n- Or use `sqlx` with async SQLite support\n- Consider WAL mode for concurrent reads
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_aibroker#109
No description provided.