fix(hub): remove stale smart_devices records when a drive is no longer reported - #2178
Open
svenvg93 wants to merge 1 commit into
Open
fix(hub): remove stale smart_devices records when a drive is no longer reported#2178svenvg93 wants to merge 1 commit into
svenvg93 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📃 Description
Fixes stale
smart_devicesrecords lingering in the database forever. When a system's device naming changes (e.g. TrueNAS/FreeBSD reassigns/dev/sdXto 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/sdgrows, one stale) with no way to tell which one was current without logging into the host directly.saveSmartDevicesnow 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
/dev/sdXafter 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.