Skip to content

Commit 100fe1a

Browse files
committed
common: make ceph_asserts suppressible
Fixes: https://tracker.ceph.com/issues/70476 Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent 358864a commit 100fe1a

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

src/common/assert.cc

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <sstream>
1818

1919
#include "include/compat.h"
20+
#include "include/str_list.h"
2021
#include "common/BackTrace.h"
2122
#include "common/Clock.h" // for ceph_clock_now()
2223
#include "common/debug.h"
@@ -70,6 +71,7 @@ namespace ceph {
7071
oss << ClibBackTrace(1);
7172
dout_emergency(oss.str());
7273

74+
bool should_abort = true;
7375
if (g_assert_context) {
7476
lderr(g_assert_context) << g_assert_msg << std::endl;
7577
*_dout << oss.str() << dendl;
@@ -78,9 +80,22 @@ namespace ceph {
7880
if (!g_assert_context->_conf->fatal_signal_handlers) {
7981
g_assert_context->_log->dump_recent();
8082
}
81-
}
8283

83-
abort();
84+
// bypass the abort?
85+
const auto supressions = get_str_list(
86+
g_assert_context->_conf.get_val<std::string>("ceph_assert_supresssions"));
87+
should_abort = std::none_of(
88+
std::begin(supressions), std::end(supressions),
89+
[file, line](const auto& supression) {
90+
return supression == fmt::format("{}:{}", file, line);
91+
});
92+
}
93+
if (should_abort) {
94+
abort();
95+
} else {
96+
dout_emergency("WARNING: ceph_assert() does NOT abort() due "
97+
"to ceph_assert_supresssions");
98+
}
8499
}
85100

86101
[[gnu::cold]] void __ceph_assert_fail(const assert_data &ctx)
@@ -151,6 +166,7 @@ namespace ceph {
151166
oss << *bt;
152167
dout_emergency(oss.str());
153168

169+
bool should_abort = true;
154170
if (g_assert_context) {
155171
lderr(g_assert_context) << g_assert_msg << std::endl;
156172
*_dout << oss.str() << dendl;
@@ -159,9 +175,22 @@ namespace ceph {
159175
if (!g_assert_context->_conf->fatal_signal_handlers) {
160176
g_assert_context->_log->dump_recent();
161177
}
162-
}
163178

164-
abort();
179+
// bypass the abort?
180+
const auto supressions = get_str_list(
181+
g_assert_context->_conf.get_val<std::string>("ceph_assert_supresssions"));
182+
should_abort = std::none_of(
183+
std::begin(supressions), std::end(supressions),
184+
[file, line](const auto& supression) {
185+
return supression == fmt::format("{}:{}", file, line);
186+
});
187+
}
188+
if (should_abort) {
189+
abort();
190+
} else {
191+
dout_emergency("WARNING: ceph_assertf() does NOT abort() due to"
192+
"to ceph_assert_supresssions");
193+
}
165194
}
166195

167196
[[gnu::cold]] void __ceph_abort(const char *file, int line,

src/common/options/global.yaml.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6718,3 +6718,10 @@ options:
67186718
desc: Enables exception throwing instead of process abort on transaction submission error.
67196719
default: false
67206720
with_legacy: false
6721+
- name: ceph_assert_supresssions
6722+
type: str
6723+
desc: Suppress specific ceph_assert instances to let the execution continue with unknown, potentially DESTRUCTIVE consequences.
6724+
fmt_desc: Comma-separated list of locations of ceph_assert in the source code.
6725+
The format is ``{file}:{line} [, {file}:{line}]``
6726+
level: dev
6727+
with_legacy: false

0 commit comments

Comments
 (0)