Skip to content

fix(hub): remove stale smart_devices records when a drive is no longer reported - #2178

Open
svenvg93 wants to merge 1 commit into
henrygd:mainfrom
svenvg93:fix/smart-devices-stale-cleanup
Open

fix(hub): remove stale smart_devices records when a drive is no longer reported#2178
svenvg93 wants to merge 1 commit into
henrygd:mainfrom
svenvg93:fix/smart-devices-stale-cleanup

Conversation

@svenvg93

@svenvg93 svenvg93 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

📃 Description

Fixes stale smart_devices records lingering in the database forever. When a system's device naming changes (e.g. TrueNAS/FreeBSD reassigns /dev/sdX to a different physical drive after reboot), the hub previously only ever upserted SMART device rows — it never removed the row for a drive that stopped being reported. This left orphaned entries in the UI showing duplicate device names (e.g. two /dev/sdg rows, one stale) with no way to tell which one was current without logging into the host directly.

saveSmartDevices now diffs the current fetch's device set against existing rows for that system and deletes anything no longer reported, in the same transaction as the upserts — so a device is pruned exactly when a successful fetch stops seeing it, and devices still present are updated in place rather than being touched unnecessarily.

Fixes #2172

🪵 Changelog

🔧 Fixed

  • SMART device records for drives no longer reported (removed, or renamed to a different /dev/sdX after a reboot) are no longer left behind as stale, duplicate entries — they're now removed from the database as soon as the next successful SMART fetch confirms they're gone.

@svenvg93
svenvg93 requested a review from henrygd as a code owner August 3, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: multiple /dev/sdg drives on truenas

1 participant