You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2019/03/05 00:29:05 UTC
[impala] 03/03: IMPALA-8274: Fix iteration of profiles in
ApplyExecStatusReport()
This is an automated email from the ASF dual-hosted git repository.
joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 110b362a52eda053caa0d177016e22a23a1a9612
Author: Michael Ho <kw...@cloudera.com>
AuthorDate: Sun Mar 3 17:29:21 2019 -0800
IMPALA-8274: Fix iteration of profiles in ApplyExecStatusReport()
The coordinator skips over any stale or duplicated status
reports of fragment instances. In the previous implementation,
the index pointing into the vector of Thrift profiles wasn't
updated when skipping over a status report. This breaks the
assumption that the status reports and thrift profiles vectors
have one-to-one correspondence. Consequently, we may end up
passing the wrong profile to InstanceStats::Update(), leading
to random crashes.
This change fixes the problem above by using iterators to
iterate through the status reports and thrift profiles vectors
and ensures that both iterators are updated on every iteration
of the loop.
Change-Id: I8bce426c7d08ffbf0f8cd26889262243a52cc752
Reviewed-on: http://gerrit.cloudera.org:8080/12651
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
be/src/runtime/coordinator-backend-state.cc | 36 ++++++++++++++++++-----------
tests/custom_cluster/test_rpc_timeout.py | 14 +++++++----
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/be/src/runtime/coordinator-backend-state.cc b/be/src/runtime/coordinator-backend-state.cc
index 605a758..8db379f 100644
--- a/be/src/runtime/coordinator-backend-state.cc
+++ b/be/src/runtime/coordinator-backend-state.cc
@@ -310,11 +310,23 @@ bool Coordinator::BackendState::ApplyExecStatusReport(
// If this backend completed previously, don't apply the update.
if (IsDoneLocked(lock)) return false;
- int idx = 0;
- const bool has_profile = thrift_profiles.profile_trees.size() > 0;
- TRuntimeProfileTree empty_profile;
- for (const FragmentInstanceExecStatusPB& instance_exec_status :
- backend_exec_status.instance_exec_status()) {
+ // Use empty profile in case profile serialization/deserialization failed.
+ // 'thrift_profiles' and 'instance_exec_status' vectors have one-to-one correspondance.
+ vector<TRuntimeProfileTree> empty_profiles;
+ vector<TRuntimeProfileTree>::const_iterator profile_iter;
+ if (UNLIKELY(thrift_profiles.profile_trees.size() == 0)) {
+ empty_profiles.resize(backend_exec_status.instance_exec_status().size());
+ profile_iter = empty_profiles.begin();
+ } else {
+ DCHECK_EQ(thrift_profiles.profile_trees.size(),
+ backend_exec_status.instance_exec_status().size());
+ profile_iter = thrift_profiles.profile_trees.begin();
+ }
+
+ for (auto status_iter = backend_exec_status.instance_exec_status().begin();
+ status_iter != backend_exec_status.instance_exec_status().end();
+ ++status_iter, ++profile_iter) {
+ const FragmentInstanceExecStatusPB& instance_exec_status = *status_iter;
int64_t report_seq_no = instance_exec_status.report_seq_no();
int instance_idx = GetInstanceIdx(instance_exec_status.fragment_instance_id());
DCHECK_EQ(instance_stats_map_.count(instance_idx), 1);
@@ -330,10 +342,7 @@ bool Coordinator::BackendState::ApplyExecStatusReport(
}
DCHECK(!instance_stats->done_);
- DCHECK(!has_profile || idx < thrift_profiles.profile_trees.size());
- const TRuntimeProfileTree& profile =
- has_profile ? thrift_profiles.profile_trees[idx++] : empty_profile;
- instance_stats->Update(instance_exec_status, profile, exec_summary,
+ instance_stats->Update(instance_exec_status, *profile_iter, exec_summary,
scan_range_progress);
// Update DML stats
@@ -566,13 +575,14 @@ void Coordinator::BackendState::InstanceStats::Update(
exec_summary_idx =
exec_summary->data_sink_id_to_idx_map[child->metadata().data_sink_id];
}
- TPlanNodeExecSummary& exec_summary = thrift_exec_summary.nodes[exec_summary_idx];
+ TPlanNodeExecSummary& node_exec_summary = thrift_exec_summary.nodes[exec_summary_idx];
+ DCHECK_EQ(node_exec_summary.fragment_idx, exec_params_.fragment().idx);
int per_fragment_instance_idx = exec_params_.per_fragment_instance_idx;
- DCHECK_LT(per_fragment_instance_idx, exec_summary.exec_stats.size())
+ DCHECK_LT(per_fragment_instance_idx, node_exec_summary.exec_stats.size())
<< " name=" << child->name()
<< " instance_id=" << PrintId(exec_params_.instance_id)
<< " fragment_idx=" << exec_params_.fragment().idx;
- TExecStats& instance_stats = exec_summary.exec_stats[per_fragment_instance_idx];
+ TExecStats& instance_stats = node_exec_summary.exec_stats[per_fragment_instance_idx];
RuntimeProfile::Counter* rows_counter = child->GetCounter("RowsReturned");
RuntimeProfile::Counter* mem_counter = child->GetCounter("PeakMemoryUsage");
@@ -580,7 +590,7 @@ void Coordinator::BackendState::InstanceStats::Update(
if (mem_counter != nullptr) instance_stats.__set_memory_used(mem_counter->value());
instance_stats.__set_latency_ns(child->local_time());
// TODO: track interesting per-node metrics
- exec_summary.__isset.exec_stats = true;
+ node_exec_summary.__isset.exec_stats = true;
}
// determine newly-completed scan ranges and update scan_range_progress
diff --git a/tests/custom_cluster/test_rpc_timeout.py b/tests/custom_cluster/test_rpc_timeout.py
index e1a959c..6ff2bf8 100644
--- a/tests/custom_cluster/test_rpc_timeout.py
+++ b/tests/custom_cluster/test_rpc_timeout.py
@@ -127,12 +127,18 @@ class TestRPCTimeout(CustomClusterTestSuite):
self.execute_query_verify_metrics(self.TEST_QUERY, None, 10)
# Inject jitter into the RPC handler of ReportExecStatus() to trigger RPC timeout.
+ # Useful for triggering IMPALA-8274.
@pytest.mark.execute_serially
@CustomClusterTestSuite.with_args("--status_report_interval_ms=100"
- " --backend_client_rpc_timeout_ms=1000")
- def test_reportexecstatus_timeout(self, vector):
- query_options = {'debug_action': 'REPORT_EXEC_STATUS_DELAY:JITTER@1500@0.5'}
- self.execute_query_verify_metrics(self.TEST_QUERY, query_options, 10)
+ " --backend_client_rpc_timeout_ms=100")
+ def test_reportexecstatus_jitter(self, vector):
+ LONG_RUNNING_QUERY = "with v as (select t1.ss_hdemo_sk as xk " +\
+ "from tpcds_parquet.store_sales t1, tpcds_parquet.store_sales t2 " +\
+ "where t1.ss_hdemo_sk = t2.ss_hdemo_sk) " +\
+ "select count(*) from v, tpcds_parquet.household_demographics t3 " +\
+ "where v.xk = t3.hd_demo_sk"
+ query_options = {'debug_action': 'REPORT_EXEC_STATUS_DELAY:JITTER@110@0.7'}
+ self.execute_query_verify_metrics(LONG_RUNNING_QUERY, query_options, 1)
# Use a small service queue memory limit and a single service thread to exercise
# the retry paths in the ReportExecStatus() RPC