This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.18.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/branch-1.18.x by this push:
new 243b8e3f1 KUDU-3712 fix flakiness in debug-util-test
243b8e3f1 is described below
commit 243b8e3f1f95c1835d4de24f29389841524ab140
Author: Alexey Serbin <[email protected]>
AuthorDate: Tue Nov 4 15:31:03 2025 -0800
KUDU-3712 fix flakiness in debug-util-test
This changelist addresses flakiness in various scenarios of
DebugUtilTest. I also took the liberty to do minor improvements
in src/kudu/util/debug-util.h
Change-Id: I934cc88e489677476b08fed376d3b522ab44af32
Reviewed-on: http://gerrit.cloudera.org:8080/23632
Reviewed-by: Marton Greber <[email protected]>
Tested-by: Marton Greber <[email protected]>
Reviewed-by: Gabriella Lotz <[email protected]>
(cherry picked from commit 920b11d4931481fe3110661f3998e54ad98d7669)
Reviewed-on: http://gerrit.cloudera.org:8080/23662
Reviewed-by: Abhishek Chennaka <[email protected]>
Tested-by: Alexey Serbin <[email protected]>
---
src/kudu/util/debug-util-test.cc | 17 ++++++++++++++---
src/kudu/util/debug-util.cc | 5 ++---
src/kudu/util/debug-util.h | 17 ++++++++---------
3 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/src/kudu/util/debug-util-test.cc b/src/kudu/util/debug-util-test.cc
index 9879c60b0..128da2fef 100644
--- a/src/kudu/util/debug-util-test.cc
+++ b/src/kudu/util/debug-util-test.cc
@@ -62,8 +62,19 @@ DECLARE_int32(stress_cpu_threads);
namespace kudu {
class DebugUtilTest : public KuduTest {
+ protected:
+ static const MonoDelta kStackCaptureTimeout;
};
+#if defined(THREAD_SANITIZER)
+// Thread sanitizer instrumentation comes with longer runtime, so it's
necessary
+// to increase stack trace capturing timeout to avoid flakiness;
+// see KUDU-3712 for details.
+const MonoDelta DebugUtilTest::kStackCaptureTimeout =
MonoDelta::FromSeconds(5);
+#else
+const MonoDelta DebugUtilTest::kStackCaptureTimeout =
MonoDelta::FromSeconds(1);
+#endif
+
TEST_F(DebugUtilTest, TestStackTrace) {
StackTrace t;
t.Collect(0);
@@ -262,7 +273,7 @@ TEST_F(DebugUtilTest, Benchmark) {
volatile int prevent_optimize = 0;
while (MonoTime::Now() < end_time) {
StackTrace trace;
- ASSERT_OK(GetThreadStack(t->tid(), &trace));
+ ASSERT_OK(GetThreadStack(t->tid(), &trace, kStackCaptureTimeout));
if (symbolize) {
prevent_optimize += trace.Symbolize().size();
}
@@ -384,7 +395,7 @@ TEST_P(RaceTest, TestStackTraceRaces) {
MonoTime end_time = MonoTime::Now() + MonoDelta::FromSeconds(1);
while (MonoTime::Now() < end_time) {
StackTrace trace;
- ASSERT_OK(GetThreadStack(t->tid(), &trace));
+ ASSERT_OK(GetThreadStack(t->tid(), &trace, kStackCaptureTimeout));
}
}
@@ -429,7 +440,7 @@ TEST_F(DebugUtilTest, TestTimeouts) {
for (int i = 0; i < 20; i++) {
StackTrace stack;
auto st = GetMonoTimeMicros();
- ASSERT_OK(GetThreadStack(t->tid(), &stack));
+ ASSERT_OK(GetThreadStack(t->tid(), &stack, kStackCaptureTimeout));
auto dur = GetMonoTimeMicros() - st;
durations.push_back(dur);
}
diff --git a/src/kudu/util/debug-util.cc b/src/kudu/util/debug-util.cc
index 17a73bfb4..87db7c2f2 100644
--- a/src/kudu/util/debug-util.cc
+++ b/src/kudu/util/debug-util.cc
@@ -502,11 +502,10 @@ bool StackTraceCollector::RevokeSigData() {
}
#endif // #ifdef __linux__ ... #else ...
-Status GetThreadStack(int64_t tid, StackTrace* stack) {
+Status GetThreadStack(int64_t tid, StackTrace* stack, MonoDelta timeout) {
StackTraceCollector c;
RETURN_NOT_OK(c.TriggerAsync(tid, stack));
- RETURN_NOT_OK(c.AwaitCollection(MonoTime::Now() +
MonoDelta::FromSeconds(1)));
- return Status::OK();
+ return c.AwaitCollection(MonoTime::Now() + timeout);
}
string DumpThreadStack(int64_t tid) {
diff --git a/src/kudu/util/debug-util.h b/src/kudu/util/debug-util.h
index ada2def77..4dbc368fd 100644
--- a/src/kudu/util/debug-util.h
+++ b/src/kudu/util/debug-util.h
@@ -14,8 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-#ifndef KUDU_UTIL_DEBUG_UTIL_H
-#define KUDU_UTIL_DEBUG_UTIL_H
+#pragma once
#include <sys/types.h>
@@ -29,6 +28,7 @@
#include "kudu/gutil/macros.h"
#include "kudu/gutil/strings/fastmem.h"
+#include "kudu/util/monotime.h"
#include "kudu/util/status.h"
#define FUTEX_WAIT 0
@@ -38,7 +38,6 @@
namespace kudu {
template <typename T> class ArrayView;
-class MonoTime;
class StackTrace;
class StackTraceCollector;
@@ -86,7 +85,9 @@ std::string DumpThreadStack(int64_t tid);
// it internally uses signals that will cause the debugger to stop. Consider
checking
// 'IsBeingDebugged()' from os-util.h before using this function for
non-critical use
// cases.
-Status GetThreadStack(int64_t tid, StackTrace* stack);
+Status GetThreadStack(int64_t tid,
+ StackTrace* stack,
+ MonoDelta timeout = MonoDelta::FromSeconds(1));
// Return the current stack trace, stringified.
std::string GetStackTrace();
@@ -120,7 +121,7 @@ void HexStackTraceToString(char* buf, size_t size);
// Efficient class for collecting and later stringifying a stack trace.
//
// Requires external synchronization.
-class StackTrace {
+class StackTrace final {
public:
// Constructs a new (uncollected) stack trace.
@@ -222,7 +223,7 @@ class StackTrace {
// Utility class for gathering a process-wide snapshot of the stack traces
// of all threads.
-class StackTraceSnapshot {
+class StackTraceSnapshot final {
public:
// The information about each thread will be gathered in a struct.
struct ThreadInfo {
@@ -288,7 +289,7 @@ class StackTraceSnapshot {
// Namely, this provides an asynchronous trigger/collect API so that many
// stack traces can be collected from many different threads in parallel using
// different instances of this object.
-class StackTraceCollector {
+class StackTraceCollector final {
public:
StackTraceCollector() = default;
StackTraceCollector(StackTraceCollector&& other) noexcept;
@@ -325,5 +326,3 @@ class StackTraceCollector {
};
} // namespace kudu
-
-#endif