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

fix tabledump and analyze parameter #340

Merged
merged 31 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f776b1b
table dump print pretty result
Teingi Jul 11, 2024
a9de68c
Merge branch '2.3.0_bug_fix' of github.com:Teingi/obdiag into 2.3.0_b…
Teingi Jul 11, 2024
27a7cad
Merge branch 'oceanbase:master' into 2.3.0_bug_fix
Teingi Jul 11, 2024
d77000a
Fix regression testing bugs
Teingi Jul 12, 2024
c46510a
Fix regression testing bugs
Teingi Jul 12, 2024
b62132f
Optimize logs
Teingi Jul 12, 2024
6228ba3
Optimize logs
Teingi Jul 12, 2024
6b286e4
Optimize logs
Teingi Jul 12, 2024
fffab14
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 15, 2024
615f04d
fix: gather tabledump
Teingi Jul 15, 2024
38f0b69
fix: gather tabledump
Teingi Jul 15, 2024
cdc8d26
Merge branch 'oceanbase:master' into 2.3.0_bug_fix
Teingi Jul 15, 2024
04e3187
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 16, 2024
832e27a
fix analyze flt_trace offline
Teingi Jul 16, 2024
a84bc71
Merge branch '2.3.0_bug_fix' of github.com:Teingi/obdiag into 2.3.0_b…
Teingi Jul 16, 2024
a0d7e2b
Merge branch 'oceanbase:master' into 2.3.0_bug_fix
Teingi Jul 16, 2024
2cb2a64
remove duplicate code & optimize log
Teingi Jul 16, 2024
44d000b
remove duplicate code & optimize log
Teingi Jul 16, 2024
502b1eb
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 16, 2024
67fd60d
fix: command auto-completion
Teingi Jul 16, 2024
848e902
fix: command auto-completion
Teingi Jul 16, 2024
845fca6
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 16, 2024
d836af6
fix: command auto-completion
Teingi Jul 16, 2024
d0586e0
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 16, 2024
c1e1d4e
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 16, 2024
3bbace4
fix analyze_parameter/analyze_variable log
Teingi Jul 16, 2024
faac571
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 16, 2024
57a6dd3
add gathering scenario sql
Teingi Jul 16, 2024
d157234
Merge remote-tracking branch 'origin/master' into 2.3.0_bug_fix
Teingi Jul 17, 2024
858b3b2
fix tabledump and analyze parameter
Teingi Jul 17, 2024
c4c060e
fix tabledump and analyze parameter
Teingi Jul 17, 2024
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
2 changes: 1 addition & 1 deletion handler/analyzer/analyze_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def analyze_parameter_default(self):
report_default_tb.add_row([row[1], row[2], row[3], row[4], tenant_id, row[6], row[11], row[7]])
fp.write(report_default_tb.get_string() + "\n")
self.stdio.print(report_default_tb.get_string())
self.stdio.print("Analyze parameter default finished. For more details, please run cmd '" + Fore.YELLOW + " cat {0}' ".format(file_name) + Style.RESET_ALL)
self.stdio.print("Analyze parameter default finished. For more details, please run cmd '" + Fore.YELLOW + " cat {0} ".format(file_name) + Style.RESET_ALL + "'")
else:
if self.parameter_file_name is None:
self.stdio.error("the version of OceanBase is lower than 4.2.2, an initialization parameter file must be provided to find non-default values")
Expand Down
38 changes: 22 additions & 16 deletions handler/gather/gather_tabledump.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def init(self):
self.table = Util.get_option(options, 'table')
user = Util.get_option(options, 'user')
password = Util.get_option(options, 'password')
if not (self.database and self.database and user and password):
self.stdio.error("option --database/--table/--user/--password not found, please provide")
if not (self.database and self.table and user):
self.stdio.error("option --database/--table/--user not found, please provide")
return False
store_dir_option = Util.get_option(options, 'store_dir')
if store_dir_option is not None and store_dir_option != './':
Expand Down Expand Up @@ -100,27 +100,31 @@ def handle(self):
if not self.init():
self.stdio.error('init failed')
return False
self.execute()
if not self.is_innner:
excute_status = self.execute()
if not self.is_innner and excute_status:
self.__print_result()

def execute(self):
try:
self.version = get_observer_version(self.context)
self.__get_table_schema()
if self.version == "4.0.0.0" or StringUtils.compare_versions_greater(self.version, "4.0.0.0"):
self.__get_table_info()
else:
self.__get_table_info_v3()
if self.__get_table_schema():
if self.version == "4.0.0.0" or StringUtils.compare_versions_greater(self.version, "4.0.0.0"):
return self.__get_table_info()
else:
return self.__get_table_info_v3()
except Exception as e:
self.stdio.error("report sql result to file: {0} failed, error: {1}".format(self.file_name, e))
self.stdio.error("report sql result failed, error: {0}".format(e))

def __get_table_schema(self):
sql = "show create table " + self.database + "." + self.table
columns, result = self.tenant_connector.execute_sql_return_columns_and_data(sql)
if result is None or len(result) == 0:
self.stdio.verbose("excute sql: {0}, result is None".format(sql))
self.__report(sql, columns, result)
try:
sql = "show create table " + self.database + "." + self.table
columns, result = self.tenant_connector.execute_sql_return_columns_and_data(sql)
if result is None or len(result) == 0:
self.stdio.verbose("excute sql: {0}, result is None".format(sql))
self.__report(sql, columns, result)
return True
except Exception as e:
self.stdio.error("show create table error {0}".format(e))

def __get_table_info(self):
try:
Expand Down Expand Up @@ -172,6 +176,7 @@ def __get_table_info(self):
return
self.stdio.print("data size {0}".format(result))
self.__report(query_data, columns, result)
return True

except Exception as e:
self.stdio.error("getTableInfo execute Exception: {0}".format(e).strip())
Expand Down Expand Up @@ -203,6 +208,7 @@ def __get_table_info_v3(self):
return
self.stdio.print("table count {0}".format(result))
self.__report(query_count, columns, result)
return True

except Exception as e:
self.stdio.error("getTableInfo execute Exception: {0}".format(e).strip())
Expand All @@ -215,7 +221,7 @@ def __report(self, sql, column_names, data):
f.write('\n\n' + 'obclient > ' + sql + '\n')
f.write(formatted_table)
except Exception as e:
self.stdio.error("report sql result to file: {0} failed, error: ".format(self.file_name))
self.stdio.error("report sql result to file: {0} failed, error:{1} ".format(self.file_name, e))

def __extract_string(self, s):
if '@' in s:
Expand Down
Loading