Improve storage collector by using dictionary delete callbacks#21500
Merged
stelfrag merged 2 commits intonetdata:masterfrom Jan 8, 2026
Merged
Improve storage collector by using dictionary delete callbacks#21500stelfrag merged 2 commits intonetdata:masterfrom
stelfrag merged 2 commits intonetdata:masterfrom
Conversation
Ensure proper deallocation of disk-related strings and reset pointers to NULL. Add metadata reset (`collected_metadata = false`) during cleanup to prevent stale data usage.
577757d to
c720aa8
Compare
thiagoftsm
approved these changes
Jan 8, 2026
Contributor
thiagoftsm
left a comment
There was a problem hiding this comment.
All disks on Windows are showing data as expected. LGTM!
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves memory management in the Windows storage collector by switching from manual cleanup to dictionary delete callbacks. The changes centralize resource cleanup, prevent memory leaks by properly freeing strings and setting pointers to NULL, and reset metadata flags to prevent stale data usage.
Key Changes
- Added dictionary delete callbacks (
dict_logical_disk_delete_cbanddict_physical_disk_delete_cb) to automate cleanup when dictionary entries are removed - Enhanced cleanup functions to properly free STRING pointers and reset them to NULL
- Added metadata flag reset (
collected_metadata = false) to prevent stale data - Simplified cleanup loops by removing manual cleanup calls (now handled by delete callbacks)
Comments suppressed due to low confidence (1)
src/collectors/windows.plugin/perflib-storage.c:162
- The RRDDIM pointer rd_split should be set to NULL after marking st_split obsolete and setting it to NULL. Additionally, the RRDDIM pointers within the nested ND_DISK_* structures should be set to NULL as well, following the comprehensive cleanup pattern used in other collectors like proc_net_dev.c. Each ND_DISK_* structure contains RRDDIM pointers that need to be invalidated when their parent RRDSET is marked obsolete.
rrdset_is_obsolete___safe_from_collector_thread(d->disk_io.st_io);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_ops.st_ops);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_util.st_util);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_busy.st_busy);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_iotime.st_iotime);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_qops.st_qops);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_await.st_await);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_svctm.st_svctm);
rrdset_is_obsolete___safe_from_collector_thread(d->disk_avgsz.st_avgsz);
rrdset_is_obsolete___safe_from_collector_thread(d->st_split);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
collected_metadata = false) during cleanup to prevent stale data usage.Summary by cubic
Switch the Windows storage collector to dictionary delete callbacks for logical and physical disks. This centralizes cleanup, fixes memory leaks, and prevents stale metadata.
Written for commit 456f627. Summary will update on new commits.