Replies: 4 comments 2 replies
-
(2) seems like a good idea with little downside? I like it. It also opens the door to a slightly more featureful assert assert, which I've often missed when writing seastar-side code, e.g., taking some arguments to print. Worth noting that the current situation is almost certainly an ODR violation when the same function is compiled with and without asserts:
Though I don't think this form is likely to bite. What is more likely to bite is if any structure changes based on |
Beta Was this translation helpful? Give feedback.
-
I like 2 (but SEASTAR_ASSERT so it's clearly not a function). |
Beta Was this translation helpful? Give feedback.
-
I agree with you and Avi, the standard C assert() has been made almost unusable because of this NDEBUG thing, so it makes sense for each library to have its own version of assert() and its own rules when assertions are disabled and enabled, and possibly how they are printed (e.g., Seastar has its own logging mechanism, maybe assert should use that). I suggest that in Seastar, we should use the on_internal_error() that we already have. Let me explain why: It does make sense for assert to behave differently in development and release builds. While in debug builds you might want an immediate crash and core dump in case of bug to make it easier to find and debug - this can lead to disasters in production applications, where a bug in some small request or operation, that should have caused that specific operation to fail, instead causes the entire server to crash on an assertion failure. In the ScyllaDB project we've been bit by this problem a lot, and I opened an issue scylladb/scylladb#7871 to "exorcise" the assert()s from ScyllaDB. One of the alternatives we ended up using a lot is already in Seastar and maybe it should use it internally - it is
I wonder if we can convert most assert() in Seastar to using on_internal_error(), like we've been trying to do in ScyllaDB. |
Beta Was this translation helpful? Give feedback.
-
By the way, regarding |
Beta Was this translation helpful? Give feedback.
-
According to the following comment in the top-level CMake file, Seastar attempts to enable
assert
s in all modes (e.g. Release). Is it still the case that all asserts in Seastar should be enabled in all modes?However, Seastar uses
assert
in both.cc
and.hh
files. Unfortunately,-DUNDEBUG
doesn't apply to header files that are included from other projects. And nor should it: it's reasonable for a project to set-DNDEBUG
on a release build because external headers may have performance sensitive asserts that should be compiled out.In Redpanda we've introduced at least 2 difficult-to-analyze bugs that would have immediately triggered a Seastar
assert
in a header file, but which was compiled out due to our use of-DNDEBUG
.I'm think about a couple ways to approach this:
.cc
filesassert
with something likeseastar_assert
that is always-on (or configurable).In Redpanda we went with (2). Any suggestions/comments on approaching this?
Beta Was this translation helpful? Give feedback.
All reactions