Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 fix bug & delete --input_parameters #648

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions plugins/rca/transaction_execute_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions plugins/rca/transaction_not_ending.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))
Expand All @@ -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:
Expand All @@ -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))
Expand Down
6 changes: 2 additions & 4 deletions plugins/rca/transaction_wait_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions src/common/diag_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 9 additions & 1 deletion src/handler/gather/gather_component_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*"}},
}

Expand Down Expand Up @@ -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):
Expand Down
Loading