Fix Data_3 timeout by parallelizing SMART collection
All checks were successful
Build and Release / build-and-release (push) Successful in 1m10s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m10s
Root cause: SMART data was collected sequentially, one drive at a time. With 5 drives taking ~500ms each, total collection time was 2.5+ seconds. When disk collector runs every 1 second, this caused overlapping collections creating resource contention. The last drive (sda/Data_3) would timeout due to the drive being accessed by the previous collection. Solution: Query all drives in parallel using futures::join_all. Now all drives get their SMART data collected simultaneously with independent 3-second timeouts, eliminating contention and reducing total collection time from 2.5+ seconds to ~500ms (the slowest single drive). Benefits: - All drives complete in ~500ms instead of 2.5+ seconds - No overlapping collections causing resource contention - Each drive gets full 3-second timeout window - sda/Data_3 should now show temperature and serial number Bump version to v0.1.223
This commit is contained in:
@@ -387,9 +387,9 @@ impl DiskCollector {
|
||||
device.to_string()
|
||||
}
|
||||
|
||||
/// Get SMART data for drives
|
||||
/// Get SMART data for drives in parallel
|
||||
async fn get_smart_data_for_drives(&self, physical_drives: &[PhysicalDrive], mergerfs_pools: &[MergerfsPool]) -> HashMap<String, SmartData> {
|
||||
let mut smart_data = HashMap::new();
|
||||
use futures::future::join_all;
|
||||
|
||||
// Collect all drive names
|
||||
let mut all_drives = std::collections::HashSet::new();
|
||||
@@ -405,9 +405,24 @@ impl DiskCollector {
|
||||
}
|
||||
}
|
||||
|
||||
// Get SMART data for each drive
|
||||
for drive_name in all_drives {
|
||||
if let Ok(data) = self.get_smart_data(&drive_name).await {
|
||||
// Collect SMART data for all drives in parallel
|
||||
let futures: Vec<_> = all_drives
|
||||
.iter()
|
||||
.map(|drive_name| {
|
||||
let drive = drive_name.clone();
|
||||
async move {
|
||||
let result = self.get_smart_data(&drive).await;
|
||||
(drive, result)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let results = join_all(futures).await;
|
||||
|
||||
// Build HashMap from results
|
||||
let mut smart_data = HashMap::new();
|
||||
for (drive_name, result) in results {
|
||||
if let Ok(data) = result {
|
||||
smart_data.insert(drive_name, data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user