IMPALA-4608: Fix fragment completion times for INSERTs

Fix a bug where completion times weren't computed if the query was an
INSERT, because the code presumed that instance 0 was always the
coordinator fragment and skipped completion time computation.

It may be that the special-casing can be removed entirely, but needs
further investigation to make sure that wouldn't trigger any div-by-0 bugs.

Change-Id: I3ce56f70d30c9e398b14b32520c815d87f81f893
Reviewed-on: http://gerrit.cloudera.org:8080/5418
Reviewed-by: Henry Robinson <[email protected]>
Tested-by: Impala Public Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/cc57a229
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/cc57a229
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/cc57a229

Branch: refs/heads/hadoop-next
Commit: cc57a229fdc7ad9fc6b3b6f2cfa3a64f7aacbd10
Parents: 02b5cce
Author: Henry Robinson <[email protected]>
Authored: Tue Dec 6 11:40:42 2016 -0800
Committer: Impala Public Jenkins <[email protected]>
Committed: Fri Dec 9 01:33:09 2016 +0000

----------------------------------------------------------------------
 be/src/runtime/coordinator.cc | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/cc57a229/be/src/runtime/coordinator.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/coordinator.cc b/be/src/runtime/coordinator.cc
index 2b446df..651d349 100644
--- a/be/src/runtime/coordinator.cc
+++ b/be/src/runtime/coordinator.cc
@@ -1668,17 +1668,14 @@ void Coordinator::ReportQuerySummary() {
   if (!fragment_instance_states_.empty()) {
     // Average all fragment instances for each fragment.
     for (FragmentInstanceState* state: fragment_instance_states_) {
-      // TODO: make profiles uniform across all fragments so we don't have
-      // to keep special-casing the coord fragment
-      if (state->fragment_idx() == 0) {
-        state->profile()->ComputeTimeInProfile();
-        UpdateExecSummary(*state);
-      } else {
-        state->profile()->ComputeTimeInProfile();
-        UpdateAverageProfile(state);
+      state->profile()->ComputeTimeInProfile();
+      UpdateAverageProfile(state);
+      // Skip coordinator fragment, if one exists.
+      // TODO: Can we remove the special casing here?
+      if (executor_ == nullptr || state->fragment_idx() != 0) {
         ComputeFragmentSummaryStats(state);
-        UpdateExecSummary(*state);
       }
+      UpdateExecSummary(*state);
     }
 
     InstanceComparator comparator;

Reply via email to