[CP] fix show trace not show in standby database

This commit is contained in:
obdev
2024-02-02 18:46:51 +00:00
committed by ob-robot
parent 29f29ee7a6
commit f4ae0ebd1b
2 changed files with 25 additions and 7 deletions

View File

@ -84,7 +84,6 @@ int ObVirtualShowTrace::retrive_all_span_info()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObMySQLTransaction trans; ObMySQLTransaction trans;
bool with_snap_shot = true;
ObMySQLProxy *mysql_proxy = GCTX.sql_proxy_; ObMySQLProxy *mysql_proxy = GCTX.sql_proxy_;
ObString trace_id; ObString trace_id;
if (OB_ISNULL(mysql_proxy)) { if (OB_ISNULL(mysql_proxy)) {
@ -93,8 +92,6 @@ int ObVirtualShowTrace::retrive_all_span_info()
} else if (OB_ISNULL(session_)) { } else if (OB_ISNULL(session_)) {
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
SERVER_LOG(WARN, "session is null", K(ret)); SERVER_LOG(WARN, "session is null", K(ret));
} else if (OB_FAIL(trans.start(mysql_proxy, effective_tenant_id_, with_snap_shot))) {
SERVER_LOG(WARN, "failed to start transaction", K(ret), K(effective_tenant_id_));
} else { } else {
int sql_len = 0; int sql_len = 0;
is_row_format_ = session_->is_row_traceformat(); is_row_format_ = session_->is_row_traceformat();
@ -123,7 +120,7 @@ int ObVirtualShowTrace::retrive_all_span_info()
{ // make sure %res destructed before execute other sql in the same transaction { // make sure %res destructed before execute other sql in the same transaction
SMART_VAR(ObMySQLProxy::MySQLResult, res) { SMART_VAR(ObMySQLProxy::MySQLResult, res) {
common::sqlclient::ObMySQLResult *result = NULL; common::sqlclient::ObMySQLResult *result = NULL;
ObISQLClient *sql_client = &trans; ObISQLClient *sql_client = mysql_proxy;
uint64_t table_id = OB_ALL_VIRTUAL_TRACE_SPAN_INFO_TID; uint64_t table_id = OB_ALL_VIRTUAL_TRACE_SPAN_INFO_TID;
ObSQLClientRetryWeak sql_client_retry_weak(sql_client, ObSQLClientRetryWeak sql_client_retry_weak(sql_client,
exec_tenant_id, exec_tenant_id,

View File

@ -243,6 +243,11 @@ void PxWorkerFunctor::operator ()(bool need_exec)
LOG_WARN("already interrupted"); LOG_WARN("already interrupted");
} }
if (OB_ISNULL(sqc_handler)) {
// do nothing
} else if (sqc_handler->get_flt_ctx().trace_id_.is_inited()) {
OBTRACE->reset();
}
PxWorkerFinishFunctor on_func_finish; PxWorkerFinishFunctor on_func_finish;
on_func_finish(); on_func_finish();
ObCurTraceId::reset(); ObCurTraceId::reset();
@ -343,9 +348,25 @@ int ObPxThreadWorker::exit()
int ObPxLocalWorker::run(ObPxRpcInitTaskArgs &task_arg) int ObPxLocalWorker::run(ObPxRpcInitTaskArgs &task_arg)
{ {
int ret = OB_SUCCESS;
ObPxSqcHandler *h = task_arg.get_sqc_handler();
if (OB_ISNULL(h)) {
} else if (h->get_flt_ctx().trace_id_.is_inited()) {
OBTRACE->init(h->get_flt_ctx());
}
{
FLTSpanGuard(px_task); FLTSpanGuard(px_task);
ObPxTaskProcess task_proc(gctx_, task_arg); ObPxTaskProcess task_proc(gctx_, task_arg);
return task_proc.process(); ret = task_proc.process();
}
if (OB_ISNULL(h)) {
} else if (h->get_flt_ctx().trace_id_.is_inited()) {
OBTRACE->reset();
}
return ret;
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////