Summary
SqliteStorage::store() and retrieve() call self.conn.lock().unwrap() without handling mutex poisoning, causing all worker threads to panic if any single thread panics while holding the storage lock.
Category
Bug
Severity
Medium
Location
- File:
src/core/storage.rs
- Line(s): 41, 55
Details
If any thread panics while holding the Mutex<Connection> lock, all subsequent calls to lock() return a PoisonError. Calling .unwrap() on a poisoned mutex causes a panic in every caller, bringing down the entire crawler engine even if the original failure was transient or isolated to one spider task.
In a concurrent crawl context (CrawlerEngine spawns many tasks), this means a single bad page can crash storage for all subsequent requests.
Suggested Fix
Use .lock().unwrap_or_else(|e| e.into_inner()) to recover the inner value from a poisoned mutex, or return an error:
// Before
let conn = self.conn.lock().unwrap();
// After (recovery)
let conn = self.conn.lock().unwrap_or_else(|e| e.into_inner());
// Or (propagate as error)
let conn = self.conn.lock().map_err(|_| StorageError::LockPoisoned)?;
Effort Estimate
15 min
Automated finding by repo-health-agent v1.0
Summary
SqliteStorage::store()andretrieve()callself.conn.lock().unwrap()without handling mutex poisoning, causing all worker threads to panic if any single thread panics while holding the storage lock.Category
Bug
Severity
Medium
Location
src/core/storage.rsDetails
If any thread panics while holding the
Mutex<Connection>lock, all subsequent calls tolock()return aPoisonError. Calling.unwrap()on a poisoned mutex causes a panic in every caller, bringing down the entire crawler engine even if the original failure was transient or isolated to one spider task.In a concurrent crawl context (
CrawlerEnginespawns many tasks), this means a single bad page can crash storage for all subsequent requests.Suggested Fix
Use
.lock().unwrap_or_else(|e| e.into_inner())to recover the inner value from a poisoned mutex, or return an error:Effort Estimate
15 min
Automated finding by repo-health-agent v1.0