make memory of TSI belong to tenant
This commit is contained in:
1
deps/oblib/src/lib/CMakeLists.txt
vendored
1
deps/oblib/src/lib/CMakeLists.txt
vendored
@ -26,6 +26,7 @@ ob_set_subtarget(oblib_lib charset
|
|||||||
ob_set_subtarget(oblib_lib common
|
ob_set_subtarget(oblib_lib common
|
||||||
ob_abort.cpp
|
ob_abort.cpp
|
||||||
ob_date_unit_type.cpp
|
ob_date_unit_type.cpp
|
||||||
|
ob_define.cpp
|
||||||
ob_lib_config.cpp
|
ob_lib_config.cpp
|
||||||
ob_name_id_def.cpp
|
ob_name_id_def.cpp
|
||||||
ob_replica_define.cpp
|
ob_replica_define.cpp
|
||||||
|
14
deps/oblib/src/lib/ob_define.cpp
vendored
Normal file
14
deps/oblib/src/lib/ob_define.cpp
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lib/ob_define.h"
|
||||||
|
__thread uint64_t tl_thread_tenant_id = oceanbase::common::OB_SERVER_TENANT_ID;
|
9
deps/oblib/src/lib/ob_define.h
vendored
9
deps/oblib/src/lib/ob_define.h
vendored
@ -2371,6 +2371,15 @@ OB_INLINE int64_t &ob_get_arb_tenant_id()
|
|||||||
RLOCAL(int64_t, arb_tenant_id);
|
RLOCAL(int64_t, arb_tenant_id);
|
||||||
return arb_tenant_id;
|
return arb_tenant_id;
|
||||||
}
|
}
|
||||||
|
extern __thread uint64_t tl_thread_tenant_id;
|
||||||
|
OB_INLINE uint64_t ob_thread_tenant_id()
|
||||||
|
{
|
||||||
|
return tl_thread_tenant_id;
|
||||||
|
}
|
||||||
|
OB_INLINE uint64_t ob_set_thread_tenant_id(uint64_t tenant_id)
|
||||||
|
{
|
||||||
|
return tl_thread_tenant_id = tenant_id;
|
||||||
|
}
|
||||||
|
|
||||||
#define GETTID() ob_gettid()
|
#define GETTID() ob_gettid()
|
||||||
#define GETTNAME() ob_get_tname()
|
#define GETTNAME() ob_get_tname()
|
||||||
|
4
deps/oblib/src/lib/stat/ob_di_tls.h
vendored
4
deps/oblib/src/lib/stat/ob_di_tls.h
vendored
@ -89,7 +89,7 @@ T* ObDITls<T, tag>::get_instance()
|
|||||||
static const char* label = get_label();
|
static const char* label = get_label();
|
||||||
di_tls.instance_ = (T*)PLACE_HOLDER;
|
di_tls.instance_ = (T*)PLACE_HOLDER;
|
||||||
// add tenant
|
// add tenant
|
||||||
ObMemAttr attr(OB_SERVER_TENANT_ID, label);
|
ObMemAttr attr(ob_thread_tenant_id(), label);
|
||||||
SET_USE_500(attr);
|
SET_USE_500(attr);
|
||||||
di_tls.instance_ = OB_NEW(T, attr);
|
di_tls.instance_ = OB_NEW(T, attr);
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ T* ObDITls<T[N], tag>::get_instance()
|
|||||||
if (OB_LIKELY(!di_tls.is_valid() && !is_thread_in_exit)) {
|
if (OB_LIKELY(!di_tls.is_valid() && !is_thread_in_exit)) {
|
||||||
static const char* label = get_label();
|
static const char* label = get_label();
|
||||||
di_tls.instance_ = (T*)PLACE_HOLDER;
|
di_tls.instance_ = (T*)PLACE_HOLDER;
|
||||||
ObMemAttr attr(OB_SERVER_TENANT_ID, label);
|
ObMemAttr attr(ob_thread_tenant_id(), label);
|
||||||
SET_USE_500(attr);
|
SET_USE_500(attr);
|
||||||
// add tenant
|
// add tenant
|
||||||
if (OB_NOT_NULL(di_tls.instance_ = (T*)ob_malloc(sizeof(T) * N, attr))) {
|
if (OB_NOT_NULL(di_tls.instance_ = (T*)ob_malloc(sizeof(T) * N, attr))) {
|
||||||
|
2
deps/oblib/src/lib/thread/thread.cpp
vendored
2
deps/oblib/src/lib/thread/thread.cpp
vendored
@ -55,6 +55,7 @@ Thread::Thread(int64_t stack_size)
|
|||||||
Thread::Thread(Runnable runnable, int64_t stack_size)
|
Thread::Thread(Runnable runnable, int64_t stack_size)
|
||||||
: pth_(0),
|
: pth_(0),
|
||||||
runnable_(runnable),
|
runnable_(runnable),
|
||||||
|
tenant_id_(OB_SERVER_TENANT_ID),
|
||||||
#ifndef OB_USE_ASAN
|
#ifndef OB_USE_ASAN
|
||||||
stack_addr_(nullptr),
|
stack_addr_(nullptr),
|
||||||
#endif
|
#endif
|
||||||
@ -242,6 +243,7 @@ void Thread::destroy_stack()
|
|||||||
void* Thread::__th_start(void *arg)
|
void* Thread::__th_start(void *arg)
|
||||||
{
|
{
|
||||||
Thread * const th = reinterpret_cast<Thread*>(arg);
|
Thread * const th = reinterpret_cast<Thread*>(arg);
|
||||||
|
ob_set_thread_tenant_id(th->get_tenant_id());
|
||||||
current_thread_ = th;
|
current_thread_ = th;
|
||||||
#ifndef OB_USE_ASAN
|
#ifndef OB_USE_ASAN
|
||||||
ObStackHeader *stack_header = ProtectedStackAllocator::stack_header(th->stack_addr_);
|
ObStackHeader *stack_header = ProtectedStackAllocator::stack_header(th->stack_addr_);
|
||||||
|
3
deps/oblib/src/lib/thread/thread.h
vendored
3
deps/oblib/src/lib/thread/thread.h
vendored
@ -47,6 +47,8 @@ public:
|
|||||||
static Thread ¤t();
|
static Thread ¤t();
|
||||||
|
|
||||||
bool has_set_stop() const;
|
bool has_set_stop() const;
|
||||||
|
uint64_t get_tenant_id() const { return tenant_id_; }
|
||||||
|
void set_tenant_id(uint64_t tenant_id) { tenant_id_ = tenant_id; }
|
||||||
|
|
||||||
OB_INLINE static int64_t update_loop_ts(int64_t t)
|
OB_INLINE static int64_t update_loop_ts(int64_t t)
|
||||||
{
|
{
|
||||||
@ -81,6 +83,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
pthread_t pth_;
|
pthread_t pth_;
|
||||||
Runnable runnable_;
|
Runnable runnable_;
|
||||||
|
uint64_t tenant_id_;
|
||||||
#ifndef OB_USE_ASAN
|
#ifndef OB_USE_ASAN
|
||||||
void *stack_addr_;
|
void *stack_addr_;
|
||||||
#endif
|
#endif
|
||||||
|
1
deps/oblib/src/lib/thread/thread_mgr.h
vendored
1
deps/oblib/src/lib/thread/thread_mgr.h
vendored
@ -118,7 +118,6 @@ public:
|
|||||||
virtual ~TGHelper() {}
|
virtual ~TGHelper() {}
|
||||||
virtual void tg_create_cb(int) = 0;
|
virtual void tg_create_cb(int) = 0;
|
||||||
virtual void tg_destroy_cb(int) = 0;
|
virtual void tg_destroy_cb(int) = 0;
|
||||||
virtual uint64_t id() const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TGHelper *&get_tenant_tg_helper();
|
extern TGHelper *&get_tenant_tg_helper();
|
||||||
|
3
deps/oblib/src/lib/thread/threads.cpp
vendored
3
deps/oblib/src/lib/thread/threads.cpp
vendored
@ -222,6 +222,9 @@ int Threads::create_thread(Thread *&thread, std::function<void()> entry)
|
|||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
} else {
|
} else {
|
||||||
thread = new (buf) Thread(entry, stack_size_);
|
thread = new (buf) Thread(entry, stack_size_);
|
||||||
|
if (nullptr != run_wrapper_) {
|
||||||
|
thread->set_tenant_id(run_wrapper_->id());
|
||||||
|
}
|
||||||
if (OB_FAIL(thread->start())) {
|
if (OB_FAIL(thread->start())) {
|
||||||
thread->~Thread();
|
thread->~Thread();
|
||||||
ob_free(thread);
|
ob_free(thread);
|
||||||
|
1
deps/oblib/src/lib/thread/threads.h
vendored
1
deps/oblib/src/lib/thread/threads.h
vendored
@ -47,6 +47,7 @@ public:
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
virtual uint64_t id() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Threads
|
class Threads
|
||||||
|
@ -280,10 +280,10 @@ int ObServerMemoryConfig::reload_config(const ObServerConfig& server_config)
|
|||||||
int64_t observer_tenant_hold = lib::get_tenant_memory_hold(OB_SERVER_TENANT_ID);
|
int64_t observer_tenant_hold = lib::get_tenant_memory_hold(OB_SERVER_TENANT_ID);
|
||||||
if (observer_tenant_hold > system_memory_) {
|
if (observer_tenant_hold > system_memory_) {
|
||||||
if (server_config._ignore_system_memory_over_limit_error) {
|
if (server_config._ignore_system_memory_over_limit_error) {
|
||||||
LOG_WARN("the hold of observer tenant is over the system_memory",
|
LOG_WARN("the hold of tenant_500 is over the system_memory",
|
||||||
K(observer_tenant_hold), K_(system_memory));
|
K(observer_tenant_hold), K_(system_memory));
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("the hold of observer tenant is over the system_memory",
|
LOG_ERROR("the hold of tenant_500 is over the system_memory",
|
||||||
K(observer_tenant_hold), K_(system_memory));
|
K(observer_tenant_hold), K_(system_memory));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user