Add log for system time and abort function

This commit is contained in:
obdev
2024-02-22 07:46:00 +00:00
committed by ob-robot
parent d60aec457f
commit 93cbf125c9
3 changed files with 18 additions and 7 deletions

View File

@ -11,8 +11,12 @@
*/
#include <lib/ob_abort.h>
#include <stdio.h>
#include "lib/ob_define.h"
#include "lib/utility/ob_backtrace.h"
void ob_abort (void) __THROW
{
fprintf(stderr, "OB_ABORT, tid: %ld, lbt: %s\n", GETTID(), oceanbase::common::lbt());
abort();
}

View File

@ -337,7 +337,7 @@ int64_t ObLogger::FileName::to_string(char * buff, const int64_t len) const
void __attribute__ ((noinline)) on_probe_abort()
{
abort();
ob_abort();
}
ProbeAction probe_str2action(const char *str)

View File

@ -22,12 +22,15 @@ using namespace oceanbase::common;
OB_SERIALIZE_MEMBER(ObMonotonicTs, mts_);
static __thread bool systime_error = false;
int64_t ObTimeUtility::current_time()
{
int err_ret = 0;
struct timeval t;
if (OB_UNLIKELY((err_ret = gettimeofday(&t, nullptr)) < 0)) {
LIB_LOG_RET(ERROR, err_ret, "gettimeofday error", K(err_ret), K(errno));
systime_error = true;
ob_abort();
}
return (static_cast<int64_t>(t.tv_sec) * 1000000L +
@ -40,10 +43,11 @@ int64_t ObTimeUtility::current_time_ns()
struct timespec ts;
if (OB_UNLIKELY((err_ret = clock_gettime(CLOCK_REALTIME, &ts)) != 0)) {
LIB_LOG_RET(WARN, err_ret, "current system not support CLOCK_REALTIME", K(err_ret), K(errno));
ob_abort();
}
return static_cast<int64_t>(ts.tv_sec) * 1000000000L +
static_cast<int64_t>(ts.tv_nsec);
systime_error = true;
ob_abort();
}
return static_cast<int64_t>(ts.tv_sec) * 1000000000L +
static_cast<int64_t>(ts.tv_nsec);
}
int64_t ObTimeUtility::current_monotonic_raw_time()
@ -73,13 +77,16 @@ int64_t ObTimeUtility::current_monotonic_raw_time()
int64_t ObTimeUtility::current_time_coarse()
{
struct timespec t;
if (OB_UNLIKELY(clock_gettime(
int err_ret = 0;
if (OB_UNLIKELY((err_ret = clock_gettime(
#ifdef HAVE_REALTIME_COARSE
CLOCK_REALTIME_COARSE,
#else
CLOCK_REALTIME,
#endif
&t))) {
&t)) != 0)) {
LIB_LOG_RET(ERROR, err_ret, "clock_gettime error", K(err_ret), K(errno));
systime_error = true;
ob_abort();
}
return (static_cast<int64_t>(t.tv_sec) * 1000000L +