IMPALA-6352: Dump backtrace on failure of TestTableSample

TestTableSample is a flaky test which has been failing very rarely due
to a possible hung thread. Therefore this patch adds a timeout to the
test and logs the backtrace of all impalads if timeout occurs, so we
can get more information on the state of those threads.

Change-Id: I73fcdd30863cee105584c947bb0c48cf872809c1
Reviewed-on: http://gerrit.cloudera.org:8080/10851
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
Bikramjeet Vig
2018-07-02 14:27:09 -07:00
committed by Impala Public Jenkins
parent f20ecadb05
commit f3b1c4bc65
3 changed files with 49 additions and 5 deletions

View File

@@ -18,6 +18,7 @@
# Tests the TABLESAMPLE clause.
import pytest
import subprocess
from tests.common.impala_test_suite import ImpalaTestSuite
from tests.common.test_vector import ImpalaTestDimension
@@ -54,8 +55,26 @@ class TestTableSample(ImpalaTestSuite):
for perc in [5, 20, 50]:
rep_sql = ""
if repeatable: rep_sql = " repeatable(1)"
result = self.client.execute(
"select count(*) from alltypes tablesample system(%s)%s" % (perc, rep_sql))
sql_stmt = "select count(*) from alltypes tablesample system(%s)%s" \
% (perc, rep_sql)
handle = self.client.execute_async(sql_stmt)
# IMPALA-6352: flaky test, possibly due to a hung thread. Wait for 500 sec before
# failing and logging the backtraces of all impalads.
is_finished = self.client.wait_for_finished_timeout(handle, 500)
assert is_finished, 'Query Timed out. Dumping backtrace of all threads in ' \
'impalads:\nthreads in the impalad1: %s \nthreads in the ' \
'impalad2: %s \nthreads in the impalad3: %s' % \
(subprocess.check_output(
"gdb -ex \"set pagination 0\" -ex \"thread apply all bt\" "
"--batch -p $(pgrep impalad | sed -n 1p)", shell=True),
subprocess.check_output(
"gdb -ex \"set pagination 0\" -ex \"thread apply all bt\" "
"--batch -p $(pgrep impalad | sed -n 2p)", shell=True),
subprocess.check_output(
"gdb -ex \"set pagination 0\" -ex \"thread apply all bt\" "
"--batch -p $(pgrep impalad | sed -n 3p)", shell=True))
result = self.client.fetch(sql_stmt, handle)
self.client.close_query(handle)
count = int(result.data[0])
assert count < baseline_count
if prev_count and repeatable: