diff --git a/deps/oblib/src/common/ob_smart_call.h b/deps/oblib/src/common/ob_smart_call.h index 32c09a1603d9dbb92310a7c7de2b4629dc98fe41..5b1fa41cf6b8688fe2712b4f8a1f69f4d51b5cba 100644 --- a/deps/oblib/src/common/ob_smart_call.h +++ b/deps/oblib/src/common/ob_smart_call.h @@ -84,9 +84,12 @@ inline int call_with_new_stack(SContext& sctx) std::function f = [&]() { \ int ret = OB_SUCCESS; \ try { \ + in_try_stmt = true; \ ret = func; \ + in_try_stmt = false; \ } catch (OB_BASE_EXCEPTION & except) { \ ret = except.get_errno(); \ + in_try_stmt = false; \ } \ return ret; \ }; \ diff --git a/deps/oblib/src/lib/coro/co_user_thread.h b/deps/oblib/src/lib/coro/co_user_thread.h index fa6e9b30df7bd0055d42cf3ef188ff7769e237f1..649d1b8bcb8c3f06e73b442b7e262fe6e019fbc1 100644 --- a/deps/oblib/src/lib/coro/co_user_thread.h +++ b/deps/oblib/src/lib/coro/co_user_thread.h @@ -294,9 +294,12 @@ int CoKThreadTemp::start() Thread* thread = nullptr; if (OB_FAIL(create_thread(thread, [this, i] { try { + common::in_try_stmt = true; this->run(i); + common::in_try_stmt = false; } catch (common::OB_BASE_EXCEPTION& except) { UNUSED(except); + common::in_try_stmt = false; } }))) { break; diff --git a/deps/oblib/src/lib/coro/thread.cpp b/deps/oblib/src/lib/coro/thread.cpp index 06eda94e7ebe938694f77f06f2563913aee0420c..c955f23d8dfab39854603c33b1f98c09681a1b89 100644 --- a/deps/oblib/src/lib/coro/thread.cpp +++ b/deps/oblib/src/lib/coro/thread.cpp @@ -221,11 +221,14 @@ void* Thread::__th_start(void* arg) th->pid_ = getpid(); th->tid_ = static_cast(syscall(__NR_gettid)); try { + in_try_stmt = true; th->runnable_(); + in_try_stmt = false; } catch (OB_BASE_EXCEPTION& except) { // we don't catch other exception because we don't know how to handle it _LOG_ERROR("Exception caught!!! errno = %d, exception info = %s", except.get_errno(), except.what()); ret = OB_ERR_UNEXPECTED; + in_try_stmt = false; } } } diff --git a/deps/oblib/src/lib/utility/ob_hang_fatal_error.cpp b/deps/oblib/src/lib/utility/ob_hang_fatal_error.cpp index 666dcc65b11426b05ca12265321b8418adeab48f..0a360559a8b1f1747e4220ce071eec4c8ff8a1b7 100644 --- a/deps/oblib/src/lib/utility/ob_hang_fatal_error.cpp +++ b/deps/oblib/src/lib/utility/ob_hang_fatal_error.cpp @@ -23,6 +23,7 @@ void right_to_die_or_duty_to_live_c() namespace oceanbase { namespace common { +RLOCAL(bool, in_try_stmt); // To die or to live, it's a problem. void right_to_die_or_duty_to_live() @@ -35,7 +36,13 @@ void right_to_die_or_duty_to_live() sleep(120); } #else - throw OB_EXCEPTION(); + if (in_try_stmt) { + throw OB_EXCEPTION(); + } else { + while (true) { + sleep(5); + } + } #endif } diff --git a/deps/oblib/src/lib/utility/ob_hang_fatal_error.h b/deps/oblib/src/lib/utility/ob_hang_fatal_error.h index 0fde57fbeacd7a60de04929e0beadd872c32df65..4c13d6d568669c1be1afde9104a3b4397db71185 100644 --- a/deps/oblib/src/lib/utility/ob_hang_fatal_error.h +++ b/deps/oblib/src/lib/utility/ob_hang_fatal_error.h @@ -14,11 +14,13 @@ #define SRC_LIB_UTILITY_OB_HANG_FATAL_ERROR_H_ #include +#include "lib/coro/co_var.h" namespace oceanbase { namespace common { extern void right_to_die_or_duty_to_live(); +extern RLOCAL(bool, in_try_stmt); struct OB_BASE_EXCEPTION : public std::exception {