| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
- Prevent lifecycle violations by improving thread ownership checks. - Address race condition when releasing PRD dimension references under active collector threads. - Refactor stale `collector_tid` handling and clarify comments.
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
sequenceDiagram
participant Svc as Service/Cleanup Thread
participant Coll as Collector Thread
participant RRD as RRDSET (Chart Metadata)
participant Mem as PRD Dimension Memory
Note over Svc,Mem: Cleanup Request Flow (rrdset_pluginsd_receive_unslot_and_cleanup)
Svc->>RRD: atomic_load(collector_tid)
RRD-->>Svc: returns active_tid
alt NEW: collector_tid != current_tid (Race Prevention)
Note right of Svc: Another thread owns the chart.
Svc->>Svc: Log warning (Skipping cleanup)
Note over Svc,RRD: CHANGED: We no longer rely on<br/>RRDSET_FLAG_COLLECTION_FINISHED<br/>as it was prone to races.
else CHANGED: collector_tid == current_tid (Collector teardown)
Svc->>Svc: internal_fatal() (if NETDATA_INTERNAL_CHECKS)
Svc->>RRD: NEW: atomic_store(collector_tid, 0)
Svc->>Mem: Free PRD dimension references
else collector_tid == 0 (Safe State)
Svc->>Mem: Free PRD dimension references
end
Note over Coll,Mem: Active Collection Flow (concurrent)
Coll->>RRD: Access chart dimensions
opt collector_tid != 0
Coll->>Mem: Dereference pointers
Note left of Mem: PRD references remain valid because<br/>Service Thread skipped cleanup.
end
Sorry, something went wrong.
There was a problem hiding this comment.
Fixes a race in pluginsd slot cleanup where PRD dimension references could be released while an active collector thread may still be dereferencing cached pointers, by tightening collector thread ownership checks during cleanup.
Changes:
src/database/rrdset-slots.c:229
nd_log_limit(&erl, NDLS_DAEMON, NDLP_WARNING,
"PLUGINSD: attempted cleanup while collector (tid %d) is still active on chart, skipping",
collector_tid);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was a problem hiding this comment.
PR is running as expected during few hours. LGTM!
Sorry, something went wrong.
* Fix cleanup logic for collector thread in RRDSET - Prevent lifecycle violations by improving thread ownership checks. - Address race condition when releasing PRD dimension references under active collector threads. - Refactor stale `collector_tid` handling and clarify comments. * Clarify collector teardown comment in `rrdset-slots.c` for improved readability
* Fix cleanup logic for collector thread in RRDSET - Prevent lifecycle violations by improving thread ownership checks. - Address race condition when releasing PRD dimension references under active collector threads. - Refactor stale `collector_tid` handling and clarify comments. * Clarify collector teardown comment in `rrdset-slots.c` for improved readability (cherry picked from commit 5419eec)
| Back | FazBrowse Home | New Git URL |
Summary
Summary by cubic
Fixes a race where pluginsd cleanup could free PRD dimension refs while a collector thread still used them. Enforces strict ownership: cleanup only proceeds in the collector thread; otherwise it is skipped.
Written for commit 4a2f22a. Summary will update on new commits.