You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by sa...@apache.org on 2016/11/08 00:58:13 UTC
[5/5] incubator-impala git commit: IMPALA-4441: Divide-by-zero in
RuntimeProfile::SummaryStatsCounter::SetStats
IMPALA-4441: Divide-by-zero in RuntimeProfile::SummaryStatsCounter::SetStats
This patch anticipates the case where total_num_values_ can be 0 and
makes sure a divide-by-zero is not possible.
Change-Id: I33f1e6fb45505dce7d79497d1632c5f63a409151
Reviewed-on: http://gerrit.cloudera.org:8080/4975
Reviewed-by: Henry Robinson <he...@cloudera.com>
Tested-by: Internal 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/e3483c44
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/e3483c44
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/e3483c44
Branch: refs/heads/master
Commit: e3483c44a3180a5c1f15a09f7c4f4f7b45ffcb44
Parents: 1a99b78
Author: Sailesh <sa...@cloudera.com>
Authored: Mon Nov 7 11:36:39 2016 -0800
Committer: Internal Jenkins <cl...@gerrit.cloudera.org>
Committed: Tue Nov 8 00:55:47 2016 +0000
----------------------------------------------------------------------
be/src/util/runtime-profile.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/e3483c44/be/src/util/runtime-profile.cc
----------------------------------------------------------------------
diff --git a/be/src/util/runtime-profile.cc b/be/src/util/runtime-profile.cc
index a9b46b9..19044fa 100644
--- a/be/src/util/runtime-profile.cc
+++ b/be/src/util/runtime-profile.cc
@@ -1037,6 +1037,8 @@ void RuntimeProfile::SummaryStatsCounter::UpdateCounter(int64_t new_value) {
}
void RuntimeProfile::SummaryStatsCounter::SetStats(const TSummaryStatsCounter& counter) {
+ // We drop this input if it looks malformed.
+ if (counter.total_num_values < 0) return;
lock_guard<SpinLock> l(lock_);
unit_ = counter.unit;
sum_ = counter.sum;
@@ -1044,7 +1046,7 @@ void RuntimeProfile::SummaryStatsCounter::SetStats(const TSummaryStatsCounter& c
min_ = counter.min_value;
max_ = counter.max_value;
- value_.Store(sum_ / total_num_values_);
+ value_.Store(total_num_values_ == 0 ? 0 : sum_ / total_num_values_);
}
int64_t RuntimeProfile::SummaryStatsCounter::MinValue() {