From c138ef32f3b5715ee8b09a00ee0554bd3a208ff2 Mon Sep 17 00:00:00 2001 From: xuyan wang <35394786+wayyoungboy@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:22:36 +0800 Subject: [PATCH] 3.0 fix bug & delete --input_parameters (#648) * fix gather_component_log add obproxy_diagnosis * fix gather_component_log add obproxy_diagnosis * fix gather_component_log add obproxy_diagnosis --- plugins/rca/transaction_execute_timeout.py | 8 ++++---- plugins/rca/transaction_not_ending.py | 8 ++++---- plugins/rca/transaction_wait_timeout.py | 6 ++---- src/common/diag_cmd.py | 2 -- src/handler/gather/gather_component_log.py | 10 +++++++++- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/plugins/rca/transaction_execute_timeout.py b/plugins/rca/transaction_execute_timeout.py index c2d8b9fb..9abf8a3e 100644 --- a/plugins/rca/transaction_execute_timeout.py +++ b/plugins/rca/transaction_execute_timeout.py @@ -51,7 +51,7 @@ def init(self, context): os.makedirs(self.work_path) self.err_type = self.input_parameters.get('err_type') if self.err_type is None or len(self.err_type.strip()) == 0: - raise RCAInitException("err_type is None. Please check the --input_parameters.") + raise RCAInitException("err_type is None. Please check the --env.") self.err_type = self.err_type.strip().lower() if self.err_type not in ["statement is timeout", "transaction is timeout"]: raise RCAInitException("err_type is {0}. It should be statement is timeout or transaction is timeout.".format(self.err_type)) @@ -82,18 +82,18 @@ def execute_statement(self): if type(self.tenant_id) in [int, str]: self.tenant_id = int(self.tenant_id) if self.tenant_id is None or self.tenant_id == 0: - raise RCAInitException("tenant_id is None. 'statement_is_timeout_scene' need it. Please check the --input_parameters.") + raise RCAInitException("tenant_id is None. 'statement_is_timeout_scene' need it. Please check the --env.") self.record.add_record("tenant_id is {0}".format(self.tenant_id)) ob_query_timeout_cursor = self.ob_connector.execute_sql_return_cursor_dictionary("select * from oceanbase.CDB_OB_SYS_VARIABLES where tenant_id='{0}' and NAME = \"ob_query_timeout\";".format(self.tenant_id)) ob_query_timeout_data = ob_query_timeout_cursor.fetchall() if len(ob_query_timeout_data) == 0: - raise RCAInitException("ob_query_timeout is None. Please check the tenant_id of --input_parameters .") + raise RCAInitException("ob_query_timeout is None. Please check the tenant_id of --env .") ob_query_timeout = ob_query_timeout_data[0].get("VALUE") self.record.add_record("ob_query_timeout is {0}".format(ob_query_timeout)) # get trace_id trace_id = self.input_parameters.get('trace_id') if trace_id is None or len(trace_id.strip()) == 0: - raise RCAInitException("trace_id is None. 'statement_is_timeout_scene' need it. Please check the --input_parameters='{\"trace_id\":\"xxxxxxxxxx\"}'.") + raise RCAInitException("trace_id is None. 'statement_is_timeout_scene' need it. Please check the --env trace_id=xxxxxxxxxx}'.") self.record.add_record("trace_id is {0}".format(trace_id)) # gather log about trace_id and "cur_query_start_time" self.gather_log.grep("{0}".format(trace_id)) diff --git a/plugins/rca/transaction_not_ending.py b/plugins/rca/transaction_not_ending.py index 443efad8..5827477f 100644 --- a/plugins/rca/transaction_not_ending.py +++ b/plugins/rca/transaction_not_ending.py @@ -66,7 +66,7 @@ def execute(self): self.record.add_record("transaction_data is {0}".format(transaction_datas)) pass if self.phase is None: - raise RCANotNeedExecuteException("phase is None. Please check --input_parameters") + raise RCANotNeedExecuteException("phase is None. Please check --env") else: if self.phase.strip().upper() == "UNSUBMITTED": self.execute_unsubmitted_phase() @@ -75,7 +75,7 @@ def execute(self): elif self.phase.strip().upper() == "REPLAY": self.execute_replay_phase() else: - raise RCANotNeedExecuteException("phase is {0}, not support. Just support 'UNSUBMITTED', 'COMMIT', 'REPLAY'. Please check --input_parameters".format(self.phase)) + raise RCANotNeedExecuteException("phase is {0}, not support. Just support 'UNSUBMITTED', 'COMMIT', 'REPLAY'. Please check --env".format(self.phase)) except Exception as e: raise RCAExecuteException("TransactionNotEndingScene execute error: {0}".format(e)) @@ -86,7 +86,7 @@ def execute(self): def execute_unsubmitted_phase(self): tx_id = self.input_parameters.get("tx_id") if tx_id is None: - raise RCANotNeedExecuteException("tx_id is None. Please check --input_parameters") + raise RCANotNeedExecuteException("tx_id is None. Please check --env") # found the transaction_data = self.ob_connector.execute_sql_return_cursor_dictionary("SELECT * FROM oceanbase.GV$OB_TRANSACTION_PARTICIPANTS where state='ACTION' and tx_id={0};".format(tx_id)).fetchall() if len(transaction_data) > 0: @@ -99,7 +99,7 @@ def execute_unsubmitted_phase(self): def execute_commit_phase(self): tx_id = self.input_parameters.get("tx_id") if tx_id is None: - raise RCANotNeedExecuteException("tx_id is None. Please check --input_parameters") + raise RCANotNeedExecuteException("tx_id is None. Please check --env") transaction_data = self.ob_connector.execute_sql_return_cursor_dictionary("SELECT * FROM oceanbase.GV$OB_TRANSACTION_PARTICIPANTS where state<>'ACTION' and tx_id={0};".format(tx_id)).fetchall() if len(transaction_data) > 0: self.record.add_record("the data in GV$OB_TRANSACTION_PARTICIPANTS by tx_id: {0}".format(transaction_data)) diff --git a/plugins/rca/transaction_wait_timeout.py b/plugins/rca/transaction_wait_timeout.py index 30901b91..724622d1 100644 --- a/plugins/rca/transaction_wait_timeout.py +++ b/plugins/rca/transaction_wait_timeout.py @@ -54,7 +54,7 @@ def init(self, context): os.makedirs(self.work_path) self.error_msg = self.input_parameters.get("error_msg") if not self.error_msg: - raise RCANotNeedExecuteException('error_msg is empty. Please input error_msg by add --input_parameters="{"err_msg":"xxx"}"') + raise RCANotNeedExecuteException('error_msg is empty. Please input error_msg by add --env err_msg=xxx') if "Shared lock conflict" in self.error_msg: self.record.add_record("err_msg type is Shared lock conflict.") self.error_msg_type = "Shared lock conflict" @@ -110,9 +110,7 @@ def execute(self): work_path_data_trans_id = self.work_path + "/data_trans_id_{0}".format(self.data_trans_id_value) self.gather_log.grep("{0}".format(self.data_trans_id_value)) self.gather_log.execute(save_path=work_path_data_trans_id) - self.record.add_suggest( - "the reason is transaction not ending (trans_id:{0}). You can get more info by 'obdiag rca run --scene=transaction_not_ending --input_parameters=\"{tx_id={0}}\"' or found {0} in the result.".format(self.data_trans_id_value) - ) + self.record.add_suggest("the reason is transaction not ending (trans_id:{0}). You can get more info by 'obdiag rca run --scene=transaction_not_ending --env tx_id=0' or found {0} in the result.".format(self.data_trans_id_value)) elif self.error_msg_type == "Lock wait timeout exceeded": # gather log about "mvcc_write conflict" work_path_mvcc_write_conflict = self.work_path + "/mvcc_write_conflict" diff --git a/src/common/diag_cmd.py b/src/common/diag_cmd.py index 0df94684..0befaf53 100644 --- a/src/common/diag_cmd.py +++ b/src/common/diag_cmd.py @@ -1056,7 +1056,6 @@ def __init__(self): super(ObdiagRCARunCommand, self).__init__('run', 'root cause analysis') self.parser.add_option('--scene', type='string', help="rca scene name. The argument is required.") self.parser.add_option('--store_dir', type='string', help='the dir to store rca result, current dir by default.', default='./obdiag_rca/') - self.parser.add_option('--input_parameters', action='callback', type='string', callback=self._env_scene, help='input parameters of scene') self.parser.add_option('--env', action='callback', type='string', callback=self._env_scene, help='env of scene') self.parser.add_option('--report_type', type='string', help='The type of the rca report, support "table", "json", "xml", "yaml", "html". default table', default='table') self.parser.add_option('-c', type='string', help='obdiag custom config', default=os.path.expanduser('~/.obdiag/config.yml')) @@ -1120,7 +1119,6 @@ def init(self, cmd, args): return self def _do_command(self, obdiag): - Util.set_option(self.opts, 'input_parameters', self.scene_input_param_map) Util.set_option(self.opts, 'env', self.scene_input_param_map) return obdiag.rca_run(self.opts) diff --git a/src/handler/gather/gather_component_log.py b/src/handler/gather/gather_component_log.py index 3a87959d..ffa67f54 100644 --- a/src/handler/gather/gather_component_log.py +++ b/src/handler/gather/gather_component_log.py @@ -38,7 +38,14 @@ class GatherComponentLogHandler(BaseShellHandler): # log_scope_list log_scope_list = { "observer": {"observer": {"key": "*observer*"}, "rootservice": {"key": "*rootservice*"}, "election": {"key": "*election*"}}, - "obproxy": {"obproxy": {"key": "*obproxy*"}, "obproxy_digest": {"key": "*obproxy_digest*"}, "obproxy_stat": {"key": "*obproxy_stat*"}, "obproxy_slow": {"key": "*obproxy_slow*"}, "obproxy_limit": {"key": "*obproxy_limit*"}}, + "obproxy": { + "obproxy": {"key": "*obproxy*"}, + "obproxy_diagnosis": {"key": "*obproxy_diagnosis*"}, + "obproxy_digest": {"key": "*obproxy_digest*"}, + "obproxy_stat": {"key": "*obproxy_stat*"}, + "obproxy_slow": {"key": "*obproxy_slow*"}, + "obproxy_limit": {"key": "*obproxy_limit*"}, + }, "oms": {"connector": {"key": "*connector.*"}, "error": {"key": "error"}, "trace.log": {"key": "trace.log"}, "metrics": {"key": "metrics*"}}, } @@ -154,6 +161,7 @@ def __check_option(self): self.scope = self.scope.strip() if self.scope not in self.log_scope_list[self.target]: raise Exception("scope option can only be {0},the {1} just support {2}".format(self.scope, self.target, self.log_scope_list)) + self.scope = {self.scope: self.log_scope_list[self.target][self.scope]} # check grep if self.grep: if isinstance(self.grep, list):