fix coredump at tenant hook
This commit is contained in:
parent
4d673a8b07
commit
158dedccd8
4
deps/easy/src/io/easy_client.c
vendored
4
deps/easy/src/io/easy_client.c
vendored
@ -19,6 +19,8 @@
|
||||
static int easy_client_uthread_wakeup_conn(easy_connection_t *c);
|
||||
static int easy_client_uthread_wakeup_session(easy_request_t *r);
|
||||
|
||||
int ob_pthread_cond_wait(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex);
|
||||
/**
|
||||
* 把session发送到addr上
|
||||
*/
|
||||
@ -148,7 +150,7 @@ void easy_client_wait(easy_client_wait_t *w, int count)
|
||||
pthread_mutex_lock(&w->mutex);
|
||||
|
||||
while (w->done_count < count) {
|
||||
pthread_cond_wait(&w->cond, &w->mutex);
|
||||
ob_pthread_cond_wait(&w->cond, &w->mutex);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&w->mutex);
|
||||
|
4
deps/oblib/src/common/ob_queue_thread.cpp
vendored
4
deps/oblib/src/common/ob_queue_thread.cpp
vendored
@ -62,7 +62,7 @@ int ObCond::wait()
|
||||
if (need_wait) {
|
||||
pthread_mutex_lock(&mutex_);
|
||||
while (OB_SUCC(ret) && false == ATOMIC_CAS(&bcond_, true, false)) {
|
||||
int tmp_ret = pthread_cond_wait(&cond_, &mutex_);
|
||||
int tmp_ret = ob_pthread_cond_wait(&cond_, &mutex_);
|
||||
if (ETIMEDOUT == tmp_ret) {
|
||||
ret = OB_TIMEOUT;
|
||||
break;
|
||||
@ -95,7 +95,7 @@ int ObCond::timedwait(const int64_t time_us)
|
||||
ts.tv_nsec = (abs_time % 1000000) * 1000;
|
||||
pthread_mutex_lock(&mutex_);
|
||||
while (OB_SUCC(ret) && false == ATOMIC_CAS(&bcond_, true, false)) {
|
||||
int tmp_ret = pthread_cond_timedwait(&cond_, &mutex_, &ts);
|
||||
int tmp_ret = ob_pthread_cond_timedwait(&cond_, &mutex_, &ts);
|
||||
if (ETIMEDOUT == tmp_ret) {
|
||||
ret = OB_TIMEOUT;
|
||||
break;
|
||||
|
1
deps/oblib/src/lib/CMakeLists.txt
vendored
1
deps/oblib/src/lib/CMakeLists.txt
vendored
@ -214,6 +214,7 @@ ob_set_subtarget(oblib_lib thread
|
||||
thread/protected_stack_allocator.cpp
|
||||
thread/thread.cpp
|
||||
thread/threads.cpp
|
||||
thread/ob_tenant_hook.cpp
|
||||
)
|
||||
|
||||
ob_set_subtarget(oblib_lib utility
|
||||
|
2
deps/oblib/src/lib/hash/ob_hashutils.h
vendored
2
deps/oblib/src/lib/hash/ob_hashutils.h
vendored
@ -156,7 +156,7 @@ public:
|
||||
~MutexWaiter() {}
|
||||
int operator()(pthread_cond_t &cond, pthread_mutex_t &lock, struct timespec &ts)
|
||||
{
|
||||
return pthread_cond_timedwait(&cond, &lock, &ts);
|
||||
return ob_pthread_cond_timedwait(&cond, &lock, &ts);
|
||||
}
|
||||
};
|
||||
|
||||
|
4
deps/oblib/src/lib/lock/cond.h
vendored
4
deps/oblib/src/lib/lock/cond.h
vendored
@ -81,7 +81,7 @@ Cond::wait_impl(const M& mutex) const
|
||||
|
||||
LockState state;
|
||||
mutex.unlock(state);
|
||||
const int rc = pthread_cond_wait(&_cond, state.mutex);
|
||||
const int rc = ob_pthread_cond_wait(&_cond, state.mutex);
|
||||
mutex.lock(state);
|
||||
|
||||
if ( 0 != rc ) {
|
||||
@ -112,7 +112,7 @@ Cond::timed_wait_impl(const M& mutex, const ObSysTime& timeout) const
|
||||
timespec ts;
|
||||
ts.tv_sec = tv.tv_sec + timeout/1000;
|
||||
ts.tv_nsec = tv.tv_usec * 1000 + ( timeout % 1000 ) * 1000000;*/
|
||||
const int rc = pthread_cond_timedwait(&_cond, state.mutex, &ts);
|
||||
const int rc = ob_pthread_cond_timedwait(&_cond, state.mutex, &ts);
|
||||
mutex.lock(state);
|
||||
|
||||
if (rc != 0) {
|
||||
|
4
deps/oblib/src/lib/lock/ob_thread_cond.cpp
vendored
4
deps/oblib/src/lib/lock/ob_thread_cond.cpp
vendored
@ -81,7 +81,7 @@ int ObThreadCond::wait_us(const uint64_t time_us)
|
||||
} else {
|
||||
ObWaitEventGuard guard(event_no_, time_us / 1000, reinterpret_cast<int64_t>(this));
|
||||
if (0 == time_us) {
|
||||
if (OB_UNLIKELY(0 != (tmp_ret = pthread_cond_wait(&cond_, &mutex_)))) {
|
||||
if (OB_UNLIKELY(0 != (tmp_ret = ob_pthread_cond_wait(&cond_, &mutex_)))) {
|
||||
ret = OB_ERR_SYS;
|
||||
COMMON_LOG(WARN, "Fail to cond wait, ", K(tmp_ret), K(ret));
|
||||
}
|
||||
@ -103,7 +103,7 @@ int ObThreadCond::wait_us(const uint64_t time_us)
|
||||
abstime.tv_sec = static_cast<decltype(abstime.tv_sec)>(std::min(static_cast<uint64_t>(std::numeric_limits<decltype(abstime.tv_sec)>::max()),
|
||||
static_cast<uint64_t>(us / 1000000)));
|
||||
abstime.tv_nsec = static_cast<decltype(abstime.tv_nsec)>(us % static_cast<uint64_t>(1000000)) * 1000;
|
||||
if (OB_UNLIKELY(0 != (tmp_ret = pthread_cond_timedwait(&cond_, &mutex_, &abstime)))) {
|
||||
if (OB_UNLIKELY(0 != (tmp_ret = ob_pthread_cond_timedwait(&cond_, &mutex_, &abstime)))) {
|
||||
if (ETIMEDOUT != tmp_ret) {
|
||||
ret = OB_ERR_SYS;
|
||||
COMMON_LOG(WARN, "Fail to timed cond wait, ", K(time_us), K(tmp_ret), K(ret));
|
||||
|
9
deps/oblib/src/lib/ob_define.h
vendored
9
deps/oblib/src/lib/ob_define.h
vendored
@ -2404,4 +2404,13 @@ inline bool is_x86() {
|
||||
#define DISABLE_WARNING_GCC_POP _Pragma("GCC diagnostic pop")
|
||||
#define DISABLE_WARNING_GCC_ATTRIBUTES DISABLE_WARNING_GCC("-Wattributes")
|
||||
|
||||
extern "C" {
|
||||
extern int ob_pthread_cond_wait(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex);
|
||||
extern int ob_pthread_cond_timedwait(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex,
|
||||
const struct timespec *__restrict __abstime);
|
||||
}
|
||||
|
||||
|
||||
#endif // OCEANBASE_COMMON_DEFINE_H_
|
||||
|
@ -3,17 +3,12 @@
|
||||
|
||||
#ifndef PERF_MODE
|
||||
#define _GNU_SOURCE 1
|
||||
#include "ob_tenant.h"
|
||||
#include "observer/ob_server_struct.h"
|
||||
#include "observer/omt/ob_multi_tenant.h"
|
||||
#include "lib/worker.h"
|
||||
#include "share/ob_define.h"
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define SYS_HOOK(func_name, ...) \
|
||||
({ \
|
||||
int ret = 0; \
|
||||
oceanbase::omt::ObTenant *tenant = NULL; \
|
||||
if (!in_sys_hook++ && OB_NOT_NULL(oceanbase::lib::Worker::self_)) { \
|
||||
oceanbase::lib::Worker::self_->set_is_blocking(true); \
|
||||
ret = real_##func_name(__VA_ARGS__); \
|
||||
@ -36,16 +31,6 @@ using namespace omt;
|
||||
|
||||
extern "C" {
|
||||
|
||||
ObTenant *sys_hook_get_tenant()
|
||||
{
|
||||
ObTenant *tenant = NULL;
|
||||
uint64_t tenant_id = 0;
|
||||
if ((tenant_id = GET_TENANT_ID()) != 0 && OB_NOT_NULL(GCTX.omt_)) {
|
||||
GCTX.omt_->get_tenant(tenant_id, tenant);
|
||||
}
|
||||
return tenant;
|
||||
}
|
||||
|
||||
int pthread_mutex_lock(pthread_mutex_t *__mutex)
|
||||
{
|
||||
static int (*real_pthread_mutex_lock)(pthread_mutex_t * __mutex) =
|
||||
@ -119,45 +104,23 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict __rwlock,
|
||||
}
|
||||
#endif
|
||||
|
||||
// objdump -t /lib64/libpthread.so.0 | grep pthread_cond_wait
|
||||
#if defined(__x86_64__)
|
||||
#define __PTHREAD_COND_WAIT_GLIBC_VERSION "GLIBC_2.3.2"
|
||||
#elif defined(__aarch64__)
|
||||
#define __PTHREAD_COND_WAIT_GLIBC_VERSION "GLIBC_2.17"
|
||||
#else
|
||||
#error arch unsupported
|
||||
#endif
|
||||
|
||||
int pthread_cond_wait(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex)
|
||||
int ob_pthread_cond_wait(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex)
|
||||
{
|
||||
static int (*real_pthread_cond_wait)(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex) =
|
||||
(typeof(real_pthread_cond_wait))dlvsym(RTLD_NEXT, "pthread_cond_wait",
|
||||
__PTHREAD_COND_WAIT_GLIBC_VERSION);
|
||||
pthread_mutex_t *__restrict __mutex) = pthread_cond_wait;
|
||||
int ret = 0;
|
||||
ret = SYS_HOOK(pthread_cond_wait, __cond, __mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// objdump -t /lib64/libpthread.so.0 | grep pthread_cond_timedwait
|
||||
#if defined(__x86_64__)
|
||||
#define __PTHREAD_COND_TIMEDWAIT_GLIBC_VERSION "GLIBC_2.3.2"
|
||||
#elif defined(__aarch64__)
|
||||
#define __PTHREAD_COND_TIMEDWAIT_GLIBC_VERSION "GLIBC_2.17"
|
||||
#else
|
||||
#error arch unsupported
|
||||
#endif
|
||||
|
||||
int pthread_cond_timedwait(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex,
|
||||
const struct timespec *__restrict __abstime)
|
||||
int ob_pthread_cond_timedwait(pthread_cond_t *__restrict __cond,
|
||||
pthread_mutex_t *__restrict __mutex,
|
||||
const struct timespec *__restrict __abstime)
|
||||
{
|
||||
static int (*real_pthread_cond_timedwait)(
|
||||
pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex,
|
||||
const struct timespec *__restrict __abstime) =
|
||||
(typeof(real_pthread_cond_timedwait))dlvsym(
|
||||
RTLD_NEXT, "pthread_cond_timedwait", __PTHREAD_COND_TIMEDWAIT_GLIBC_VERSION);
|
||||
const struct timespec *__restrict __abstime) = pthread_cond_timedwait;
|
||||
int ret = 0;
|
||||
ret = SYS_HOOK(pthread_cond_timedwait, __cond, __mutex, __abstime);
|
||||
return ret;
|
@ -112,7 +112,6 @@ ob_set_subtarget(ob_server omt
|
||||
omt/ob_th_worker.cpp
|
||||
omt/ob_worker_processor.cpp
|
||||
omt/ob_multi_tenant_operator.cpp
|
||||
omt/ob_tenant_hook.cpp
|
||||
omt/ob_tenant_srs_mgr.cpp
|
||||
omt/ob_tenant_srs.cpp
|
||||
)
|
||||
|
@ -153,7 +153,7 @@ void ObSchemaConstructTask::wait(const int64_t version)
|
||||
}
|
||||
int rc = 0;
|
||||
do {
|
||||
rc = pthread_cond_timedwait(&schema_cond_, &schema_mutex_, &ts);
|
||||
rc = ob_pthread_cond_timedwait(&schema_cond_, &schema_mutex_, &ts);
|
||||
} while (0);
|
||||
(void) rc; // make compiler happy
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user