add pcode info in __all_virtual_thread
This commit is contained in:
1
deps/oblib/src/lib/thread/thread.cpp
vendored
1
deps/oblib/src/lib/thread/thread.cpp
vendored
@ -36,6 +36,7 @@ thread_local pthread_t Thread::thread_joined_ = 0;
|
||||
thread_local int64_t Thread::sleep_us_ = 0;
|
||||
thread_local int64_t Thread::blocking_ts_ = 0;
|
||||
thread_local ObAddr Thread::rpc_dest_addr_;
|
||||
thread_local obrpc::ObRpcPacketCode Thread::pcode_ = obrpc::ObRpcPacketCode::OB_INVALID_RPC_CODE;
|
||||
thread_local uint8_t Thread::wait_event_ = 0;
|
||||
thread_local Thread* Thread::current_thread_ = nullptr;
|
||||
int64_t Thread::total_thread_count_ = 0;
|
||||
|
11
deps/oblib/src/lib/thread/thread.h
vendored
11
deps/oblib/src/lib/thread/thread.h
vendored
@ -18,6 +18,7 @@
|
||||
#include "lib/utility/ob_macro_utils.h"
|
||||
#include "lib/lock/ob_latch.h"
|
||||
#include "lib/net/ob_addr.h"
|
||||
#include "rpc/obrpc/ob_rpc_packet.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace lib {
|
||||
@ -126,17 +127,20 @@ public:
|
||||
class RpcGuard : public BaseWaitGuard
|
||||
{
|
||||
public:
|
||||
OB_INLINE explicit RpcGuard(const easy_addr_t& addr)
|
||||
OB_INLINE explicit RpcGuard(const easy_addr_t& addr, obrpc::ObRpcPacketCode pcode)
|
||||
{
|
||||
IGNORE_RETURN new (&rpc_dest_addr_) ObAddr(addr);
|
||||
pcode_ = pcode;
|
||||
}
|
||||
OB_INLINE explicit RpcGuard(const ObAddr& addr)
|
||||
OB_INLINE explicit RpcGuard(const ObAddr& addr, obrpc::ObRpcPacketCode pcode)
|
||||
{
|
||||
IGNORE_RETURN new (&rpc_dest_addr_) ObAddr(addr);
|
||||
pcode_ = pcode;
|
||||
}
|
||||
~RpcGuard()
|
||||
{
|
||||
rpc_dest_addr_.reset();
|
||||
pcode_ = obrpc::ObRpcPacketCode::OB_INVALID_RPC_CODE;
|
||||
}
|
||||
};
|
||||
|
||||
@ -144,13 +148,14 @@ public:
|
||||
static constexpr uint8_t WAIT_IN_TENANT_QUEUE = (1 << 1);
|
||||
static constexpr uint8_t WAIT_FOR_IO_EVENT = (1 << 2);
|
||||
static constexpr uint8_t WAIT_FOR_LOCAL_RETRY = (1 << 3); //Statistics of local retry waiting time for dynamically increasing threads.
|
||||
static constexpr uint8_t WAIT_FOR_PX_MSG = (1 << 4);
|
||||
static constexpr uint8_t WAIT_FOR_PX_MSG = (1 << 4);
|
||||
// for thread diagnose, maybe replace it with union later.
|
||||
static thread_local int64_t loop_ts_;
|
||||
static thread_local pthread_t thread_joined_;
|
||||
static thread_local int64_t sleep_us_;
|
||||
static thread_local int64_t blocking_ts_;
|
||||
static thread_local ObAddr rpc_dest_addr_;
|
||||
static thread_local obrpc::ObRpcPacketCode pcode_;
|
||||
static thread_local uint8_t wait_event_;
|
||||
private:
|
||||
static void* __th_start(void *th);
|
||||
|
10
deps/oblib/src/rpc/frame/ob_req_transport.cpp
vendored
10
deps/oblib/src/rpc/frame/ob_req_transport.cpp
vendored
@ -440,10 +440,7 @@ ObPacket *ObReqTransport::send_session(easy_session_t *s) const
|
||||
s->addr.cidx = balance_assign(s);
|
||||
}
|
||||
|
||||
{
|
||||
lib::Thread::RpcGuard guard(s->addr);
|
||||
pkt = reinterpret_cast<ObPacket*>(easy_client_send(eio_, s->addr, s));
|
||||
}
|
||||
pkt = reinterpret_cast<ObPacket*>(easy_client_send(eio_, s->addr, s));
|
||||
if (NULL == pkt) {
|
||||
char buff[OB_SERVER_ADDR_STR_LEN] = {'\0'};
|
||||
easy_inet_addr_to_str(&s->addr, buff, OB_SERVER_ADDR_STR_LEN);
|
||||
@ -496,7 +493,10 @@ int ObReqTransport::send(const Request &req, Result &r) const
|
||||
EVENT_ADD(RPC_PACKET_OUT_BYTES,
|
||||
req.const_pkt().get_clen() + req.const_pkt().get_header_size() + common::OB_NET_HEADER_LENGTH);
|
||||
|
||||
r.pkt_ = reinterpret_cast<obrpc::ObRpcPacket*>(send_session(req.s_));
|
||||
{
|
||||
lib::Thread::RpcGuard guard(req.s_->addr, req.const_pkt().get_pcode());
|
||||
r.pkt_ = reinterpret_cast<obrpc::ObRpcPacket*>(send_session(req.s_));
|
||||
}
|
||||
if (NULL == r.pkt_) {
|
||||
easy_error = req.s_->error;
|
||||
if (EASY_TIMEOUT == easy_error) {
|
||||
|
2
deps/oblib/src/rpc/obrpc/ob_poc_rpc_proxy.h
vendored
2
deps/oblib/src/rpc/obrpc/ob_poc_rpc_proxy.h
vendored
@ -132,7 +132,7 @@ public:
|
||||
pnio_group_id = ObPocRpcServer::RATELIMIT_PNIO_GROUP;
|
||||
}
|
||||
{
|
||||
lib::Thread::RpcGuard guard(addr);
|
||||
lib::Thread::RpcGuard guard(addr, pcode);
|
||||
if (OB_FAIL(rpc_encode_req(proxy, pool, pcode, args, opts, req, req_sz, false))) {
|
||||
RPC_LOG(WARN, "rpc encode req fail", K(ret));
|
||||
} else if(OB_FAIL(check_blacklist(addr))) {
|
||||
|
@ -1917,14 +1917,22 @@ int dump_thread_info(lua_State *L)
|
||||
}
|
||||
} else if (sizeof(ObAddr) == process_vm_readv(pid, &local_iov, 1, &remote_iov, 1, 0)
|
||||
&& addr.is_valid()) {
|
||||
int ret = 0;
|
||||
if ((ret = snprintf(wait_event, BUF_LEN, "rpc to ")) > 0) {
|
||||
IGNORE_RETURN addr.to_string(wait_event + ret, BUF_LEN - ret);
|
||||
GET_OTHER_TSI_ADDR(pcode, &Thread::pcode_);
|
||||
int64_t pos1 = 0;
|
||||
int64_t pos2 = 0;
|
||||
if (((pos1 = snprintf(wait_event, 37, "rpc 0x%X(%s", pcode, obrpc::ObRpcPacketSet::instance().name_of_idx(obrpc::ObRpcPacketSet::instance().idx_of_pcode(pcode)) + 3)) > 0)
|
||||
&& ((pos2 = snprintf(wait_event + std::min(36L, pos1), 6, ") to ")) > 0)) {
|
||||
int64_t pos = std::min(36L, pos1) + std::min(5L, pos2);
|
||||
pos += addr.to_string(wait_event + pos, BUF_LEN - pos);
|
||||
}
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_IN_TENANT_QUEUE & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event, BUF_LEN, "tenant worker request");
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_FOR_IO_EVENT & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event, BUF_LEN, "IO events");
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_FOR_LOCAL_RETRY & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event, BUF_LEN, "local retry");
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_FOR_PX_MSG & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event, BUF_LEN, "px message");
|
||||
} else if (0 != sleep_us) {
|
||||
IGNORE_RETURN snprintf(wait_event, BUF_LEN, "%ld us", sleep_us);
|
||||
} else if (0 != blocking_ts) {
|
||||
|
@ -144,14 +144,22 @@ int ObAllVirtualThread::inner_get_next_row(common::ObNewRow *&row)
|
||||
}
|
||||
} else if (sizeof(ObAddr) == process_vm_readv(pid, &local_iov, 1, &remote_iov, 1, 0)
|
||||
&& addr.is_valid()) {
|
||||
int ret = 0;
|
||||
if ((ret = snprintf(wait_event_, 64, "rpc to ")) > 0) {
|
||||
IGNORE_RETURN addr.to_string(wait_event_ + ret, 64 - ret);
|
||||
GET_OTHER_TSI_ADDR(pcode, &Thread::pcode_);
|
||||
int64_t pos1 = 0;
|
||||
int64_t pos2 = 0;
|
||||
if (((pos1 = snprintf(wait_event_, 37, "rpc 0x%X(%s", pcode, obrpc::ObRpcPacketSet::instance().name_of_idx(obrpc::ObRpcPacketSet::instance().idx_of_pcode(pcode)) + 3)) > 0)
|
||||
&& ((pos2 = snprintf(wait_event_ + std::min(36L, pos1), 6, ") to ")) > 0)) {
|
||||
int64_t pos = std::min(36L, pos1) + std::min(5L, pos2);
|
||||
pos += addr.to_string(wait_event_ + pos, 64 - pos);
|
||||
}
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_IN_TENANT_QUEUE & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event_, 64, "tenant worker requests");
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_FOR_IO_EVENT & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event_, 64, "IO events");
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_FOR_LOCAL_RETRY & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event_, 64, "local retry");
|
||||
} else if (0 != blocking_ts && (0 != (Thread::WAIT_FOR_PX_MSG & event))) {
|
||||
IGNORE_RETURN snprintf(wait_event_, 64, "px message");
|
||||
} else if (0 != sleep_us) {
|
||||
IGNORE_RETURN snprintf(wait_event_, 64, "%ld us", sleep_us);
|
||||
} else if (0 != blocking_ts) {
|
||||
|
Reference in New Issue
Block a user