From a496e671a7b43426ea9e0d0e9181bf05b8999e44 Mon Sep 17 00:00:00 2001 From: zh0 Date: Mon, 28 Mar 2022 16:35:13 +0800 Subject: [PATCH] change record and print trace log config parameter --- deps/oblib/src/lib/oblog/ob_trace_log.h | 38 +++++++++++------------ src/observer/ob_server_reload_config.cpp | 2 +- src/share/parameter/ob_parameter_seed.ipp | 4 +-- src/storage/transaction/ob_trans_ctx.cpp | 6 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/deps/oblib/src/lib/oblog/ob_trace_log.h b/deps/oblib/src/lib/oblog/ob_trace_log.h index 190698f675..24847e1ed0 100644 --- a/deps/oblib/src/lib/oblog/ob_trace_log.h +++ b/deps/oblib/src/lib/oblog/ob_trace_log.h @@ -51,36 +51,36 @@ printable; \ }) -#define NG_TRACE_EXT_TIMES(times, ...) \ - if (CHECK_TRACE_TIMES(times, 500, NULL)) { \ - NG_TRACE_EXT(__VA_ARGS__); \ +#define NG_TRACE_EXT_TIMES(times, ...) \ + if (oceanbase::lib::is_trace_log_enabled() && CHECK_TRACE_TIMES(times, 500, NULL)) { \ + NG_TRACE_EXT(__VA_ARGS__); \ } -#define NG_TRACE_TIMES(times, ...) \ - if (CHECK_TRACE_TIMES(times, 500, NULL)) { \ - NG_TRACE(__VA_ARGS__); \ +#define NG_TRACE_TIMES(times, ...) \ + if (oceanbase::lib::is_trace_log_enabled() && CHECK_TRACE_TIMES(times, 500, NULL)) { \ + NG_TRACE(__VA_ARGS__); \ } -#define NG_TRACE_TIMES_WITH_TRACE_ID(times, tmp_cur_trace_id, ...) \ - if (CHECK_TRACE_TIMES(times, 500, tmp_cur_trace_id)) { \ - NG_TRACE(__VA_ARGS__); \ +#define NG_TRACE_TIMES_WITH_TRACE_ID(times, tmp_cur_trace_id, ...) \ + if (oceanbase::lib::is_trace_log_enabled() && CHECK_TRACE_TIMES(times, 500, tmp_cur_trace_id)) { \ + NG_TRACE(__VA_ARGS__); \ } // Ordinary print log level, judged according to the current system configuration level -#define PRINT_TRACE(log_buffer) \ - if (OB_TRACE_CONFIG::get_log_level() <= OB_LOGGER.get_log_level()) { \ - if (NULL != log_buffer) { \ - ::oceanbase::common::OB_PRINT("[TRACE]", OB_LOG_LEVEL_DIRECT(TRACE), "[normal]", "TRACE", log_buffer); \ - } \ +#define PRINT_TRACE(log_buffer) \ + if (oceanbase::lib::is_trace_log_enabled() && OB_TRACE_CONFIG::get_log_level() <= OB_LOGGER.get_log_level()) { \ + if (NULL != log_buffer) { \ + ::oceanbase::common::OB_PRINT("[TRACE]", OB_LOG_LEVEL_DIRECT(TRACE), "[normal]", "TRACE", log_buffer); \ + } \ } // For logs that are forced to be printed, you can also judge according to the log level: if it is ERROR level, it will // not print, and other levels will be forced to print -#define FORCE_PRINT_TRACE(log_buffer, HEAD) \ - if (OB_LOGGER.get_log_level() != ObLogger::LogLevel::LOG_ERROR) { \ - if (NULL != log_buffer) { \ - ::oceanbase::common::OB_PRINT("[TRACE]", OB_LOG_LEVEL_DIRECT(TRACE), HEAD, "TRACE", *log_buffer); \ - } \ +#define FORCE_PRINT_TRACE(log_buffer, HEAD) \ + if (oceanbase::lib::is_trace_log_enabled() && OB_LOGGER.get_log_level() != ObLogger::LogLevel::LOG_ERROR) { \ + if (NULL != log_buffer) { \ + ::oceanbase::common::OB_PRINT("[TRACE]", OB_LOG_LEVEL_DIRECT(TRACE), HEAD, "TRACE", *log_buffer); \ + } \ } namespace oceanbase { diff --git a/src/observer/ob_server_reload_config.cpp b/src/observer/ob_server_reload_config.cpp index 8f08bfc3ae..47444f51d2 100644 --- a/src/observer/ob_server_reload_config.cpp +++ b/src/observer/ob_server_reload_config.cpp @@ -124,7 +124,7 @@ int ObServerReloadConfig::operator()() } (void)reload_diagnose_info_config(GCONF.enable_perf_event); - (void)reload_trace_log_config(GCONF.enable_sql_audit); + (void)reload_trace_log_config(GCONF.enable_record_trace_log); ObTenantManager::get_instance().reload_config(); } diff --git a/src/share/parameter/ob_parameter_seed.ipp b/src/share/parameter/ob_parameter_seed.ipp index 0e7478ebfd..17d65b0f18 100644 --- a/src/share/parameter/ob_parameter_seed.ipp +++ b/src/share/parameter/ob_parameter_seed.ipp @@ -111,8 +111,8 @@ DEF_BOOL(enable_one_phase_commit, OB_CLUSTER_PARAMETER, "False", "enable one pha ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); DEPRECATED_DEF_BOOL(enable_pg, OB_CLUSTER_PARAMETER, "False", "open partition group", ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); -DEF_BOOL(enable_record_trace_log, OB_CLUSTER_PARAMETER, "False", - "specifies whether to always record the trace log. The default value is False.", +DEF_BOOL(enable_record_trace_log, OB_CLUSTER_PARAMETER, "True", + "specifies whether to always record the trace log. The default value is True.", ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); DEF_INT(system_trace_level, OB_CLUSTER_PARAMETER, "1", "[0,2]", "system trace log level, 0:none, 1:standard, 2:debug. " diff --git a/src/storage/transaction/ob_trans_ctx.cpp b/src/storage/transaction/ob_trans_ctx.cpp index b049ed630d..f4ce74c96e 100644 --- a/src/storage/transaction/ob_trans_ctx.cpp +++ b/src/storage/transaction/ob_trans_ctx.cpp @@ -357,16 +357,16 @@ int ObTransCtx::set_partition_trans_ctx_mgr(ObPartitionTransCtxMgr* partition_mg int ObTransCtx::alloc_audit_rec_and_trace_log_(ObTransService* trans_service, ObTransTraceLog*& trace_log) { int ret = OB_SUCCESS; - // 1. sql_audit is on. If fail to get recod but revert successfully, + // 1. enable_record_trace_log is on. If fail to get recod but revert successfully, // it needs to be allocated dynamically. Return error if fail to revert. - // 2. sql_audit is off. Trace log is not required to be recorded + // 2. enable_record_trace_log is off. Trace log is not required to be recorded bool need_alloc = true; ObTransTraceLog* tmp_tlog = NULL; if (OB_ISNULL(trans_service)) { TRANS_LOG(WARN, "invalid argument", K(trans_service)); ret = OB_INVALID_ARGUMENT; - } else if (!GCONF.enable_sql_audit) { + } else if (!oceanbase::lib::is_trace_log_enabled()) { need_alloc = false; ret = OB_SUCCESS; } else { -- GitLab