mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
In clickhouse-test: Updated check for hung queries
This commit is contained in:
parent
205c0f7fbb
commit
0106040a2f
@ -99,7 +99,7 @@ def get_processlist(client_cmd):
|
||||
|
||||
|
||||
def get_stacktraces(server_pid):
|
||||
cmd = "gdb -q -ex 'set pagination off' -ex 'backtrace' -ex 'thread apply all backtrace' -ex 'detach' -ex 'quit' --pid {} 2>/dev/null".format(server_pid)
|
||||
cmd = "gdb -batch -ex 'thread apply all backtrace' -p {} 2>/dev/null".format(server_pid)
|
||||
try:
|
||||
return subprocess.check_output(cmd, shell=True)
|
||||
except Exception as ex:
|
||||
@ -107,12 +107,11 @@ def get_stacktraces(server_pid):
|
||||
|
||||
|
||||
def get_server_pid(server_tcp_port):
|
||||
cmd = "lsof -i tcp:{port} | fgrep 'TCP *:{port} (LISTEN)'".format(port=server_tcp_port)
|
||||
cmd = "lsof -i tcp:{port} -s tcp:LISTEN -Fp | gawk '/^p[0-9]+$/{{print substr($0, 2)}}'".format(port=server_tcp_port)
|
||||
try:
|
||||
output = subprocess.check_output(cmd, shell=True)
|
||||
if output:
|
||||
columns = output.strip().split(' ')
|
||||
return int(columns[1])
|
||||
return int(output[1:])
|
||||
else:
|
||||
return None # server dead
|
||||
except Exception as ex:
|
||||
@ -451,17 +450,26 @@ def main(args):
|
||||
total_tests_run += tests_n
|
||||
|
||||
if args.hung_check:
|
||||
processlist = get_processlist(args.client_with_database)
|
||||
if processlist:
|
||||
server_pid = get_server_pid(os.getenv("CLICKHOUSE_PORT_TCP", '9000'))
|
||||
print(colored("\nFound hung queries in processlist:", args, "red", attrs=["bold"]))
|
||||
print(processlist)
|
||||
if server_pid:
|
||||
clickhouse_tcp_port = os.getenv("CLICKHOUSE_PORT_TCP", '9000')
|
||||
server_pid = get_server_pid(clickhouse_tcp_port)
|
||||
if server_pid:
|
||||
print("\nLocated ClickHouse server process {} listening at TCP port {}".format(server_pid, clickhouse_tcp_port))
|
||||
processlist = get_processlist(args.client_with_database)
|
||||
if processlist:
|
||||
print(colored("\nFound hung queries in processlist:", args, "red", attrs=["bold"]))
|
||||
print(processlist)
|
||||
|
||||
print("\nStacktraces of all threads:")
|
||||
print(get_stacktraces(server_pid))
|
||||
exit_code = 1
|
||||
exit_code = 1
|
||||
else:
|
||||
print(colored("\nNo queries hung.", args, "green", attrs=["bold"]))
|
||||
else:
|
||||
print(colored("\nNo queries hung.", args, "green", attrs=["bold"]))
|
||||
print(
|
||||
colored(
|
||||
"\nUnable to locate ClickHouse server process listening at TCP port {}. "
|
||||
"It must have crashed or exited prematurely!".format(clickhouse_tcp_port),
|
||||
args, "red", attrs=["bold"]))
|
||||
|
||||
if total_tests_run == 0:
|
||||
print("No tests were run.")
|
||||
|
Loading…
Reference in New Issue
Block a user