Repository navigation
Conversation
…ounters When a daemon exists in daemon_state but has no perf counter instances (e.g., a destroyed OSD with null FSID), the get_perf_schema_python() function would crash with an assertion failure: /src/mgr/PyFormatter.h: 84: FAILED ceph_assert(cursor != root) This occurred because the function unconditionally called close_section() after iterating through perf_counters.instances, even when the collection was empty and no sections had been opened. The fix adds an early continue to skip daemons with empty perf counter instances, preventing the crash while still properly handling daemons that do have counters. Reproduction scenario: 1. Destroy an OSD: ceph osd destroy <id> --yes-i-really-mean-it 2. Wait for telemetry module to query perf schema 3. MGR crashes with assertion failure Fixes: https://tracker.ceph.com/issues/74693 Signed-off-by: Stephen Thompson <[email protected]>
|
Can one of the admins verify this patch? |
13 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can someone please review this PR? |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
ok to test |
| // Skip daemons with no perf counter instances (e.g., destroyed OSDs) | ||
| // to avoid closing sections that were never opened | ||
| // Fixes: https://tracker.ceph.com/issues/74693 |
There was a problem hiding this comment.
please drop the "Fixes" line, as this is not ceph's convention. you already include this tag in the commit message.
| // Fixes: https://tracker.ceph.com/issues/74693 | ||
| if (state->perf_counters.instances.empty()) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
instead of skipping the perf counters and changing the schema of the output. probably we can improve the formatting using Formatter::ArraySection to manage the section's lifecycle with RAII, like:
with_gil(no_gil, [&, key = ceph::to_string(key), state = state] {
std::string key_name, prev_key_name;
perf_counter_label_pairs prev_key_labels;
Formatter::ObjectSection counter_section(f, key.c_str());
std::optional<Formatter::ArraySection> array_section;
std::optional<Formatter::ObjectSection> counter_object_section;
std::optional<Formatter::ObjectSection> counters_section;
for (const auto &[counter_name_with_labels, _] :
state->perf_counters.instances) {
// ... compute key_name, key_labels, type ...
if (prev_key_name != key_name) {
// reset closes 'counters' then 'counter object' (declaration order,
// reversed at destruction) before emplacing the new array section
counters_section.reset();
counter_object_section.reset();
prev_key_name = key_name;
prev_key_labels = key_labels;
array_section.emplace(f, key_name);
counter_object_section.emplace(f, "");
for (Formatter::ObjectSection ls{f, "labels"};
const auto &label : key_labels) {
f.dump_string(label.first, label.second);
}
counters_section.emplace(f, "counters");
dump_sub_counter_information(&f, type);
} else if (prev_key_name == key_name && prev_key_labels == key_labels) {
dump_sub_counter_information(&f, type);
} else {
counters_section.reset();
counter_object_section.reset();
counter_object_section.emplace(f, "");
for (Formatter::ObjectSection ls{f, "labels"};
const auto &label : key_labels) {
f.dump_string(label.first, label.second);
}
counters_section.emplace(f, "counters");
dump_sub_counter_information(&f, type);
}
}
// no close_section() calls needed -- all sections close via RAII
});what do you think?
There was a problem hiding this comment.
+1ing this approach, I was working on a branch to resolve this issue to support unit tests within the Mgr, and have pushed similar changes here, some of the comments are superfluous but I had them in while working through implementation:
main...stzuraski898:ceph:wip-sz-75745-OSD-perf-schema-no-counters
|
It appears that a PR was merged yesterday in response to https://tracker.ceph.com/issues/75745, which was made in response to a similar issue found during unit testing. I believe we'll need to rebase onto main when implementing the RAII approach. This PR can be found here: |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
ok to test |
|
I believe this PR is redundant, #69181 has been merged and covers the changes requested by Kefu in this PR's review. |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution! |
Problem
When a daemon exists in
daemon_statebut has no perf counter instances (e.g., a destroyed OSD with null FSID00000000-0000-0000-0000-000000000000), theget_perf_schema_python()function crashes with an assertion failure:Call stack:
This causes MGR daemons to crash every 60-90 seconds when the telemetry module iterates through all OSDs and encounters a destroyed one.
Root Cause
In
get_perf_schema_python(), when iterating through daemons:daemonsis not emptyFormatter::ObjectSectionfor the daemon key (RAII-managed)state->perf_counters.instancesnever executes because the collection is emptyf.close_section()twicecursor != rootinPyFormatter::close_section()Solution
Add an early
continueto skip daemons with emptyperf_counters.instancesbefore entering thewith_gilblock. This prevents the crash while still properly handling daemons that do have perf counters.Reproduction
Testing
Comparison with Similar Code
get_unlabeled_perf_schema_python()handles this case correctly because it opens a section before the loop and closes it after - properly balanced even if the loop is empty. This fix alignsget_perf_schema_python()with that pattern by avoiding the problematic code path entirely.Fixes: https://tracker.ceph.com/issues/74693