You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2019/09/17 17:53:47 UTC

[impala] 03/04: IMPALA-8947: scratch alloc error uses wrong metric

This is an automated email from the ASF dual-hosted git repository.

tarmstrong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 451d31f2b45d0bfdfab8d8110cc63b06a061849a
Author: Tim Armstrong <ta...@cloudera.com>
AuthorDate: Mon Sep 16 12:42:39 2019 -0700

    IMPALA-8947: scratch alloc error uses wrong metric
    
    Use the global metric instead of the per-FileGroup
    counter.
    
    Testing:
    Updated unit test to validate the error message in
    a case where there are two FileGroups.
    
    Change-Id: I2732dcd49c277d5d278fad68efa6ef381bc0eb81
    Reviewed-on: http://gerrit.cloudera.org:8080/14236
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/runtime/tmp-file-mgr-test.cc | 10 ++++++++++
 be/src/runtime/tmp-file-mgr.cc      |  3 ++-
 be/src/util/metrics.h               |  2 ++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/be/src/runtime/tmp-file-mgr-test.cc b/be/src/runtime/tmp-file-mgr-test.cc
index 9b852a6..075ee75 100644
--- a/be/src/runtime/tmp-file-mgr-test.cc
+++ b/be/src/runtime/tmp-file-mgr-test.cc
@@ -787,8 +787,18 @@ TEST_F(TmpFileMgrTest, TestDirectoryLimitsExhausted) {
   // The directories are at capacity, so allocations should fail.
   Status err1 = GroupAllocateSpace(&file_group_1, ALLOC_SIZE, &alloc_file, &offset);
   ASSERT_EQ(err1.code(), TErrorCode::SCRATCH_ALLOCATION_FAILED);
+  EXPECT_STR_CONTAINS(err1.GetDetail(), "Could not create files in any configured "
+      "scratch directories (--scratch_dirs=/tmp/tmp-file-mgr-test.1/impala-scratch,"
+      "/tmp/tmp-file-mgr-test.2/impala-scratch)");
+  EXPECT_STR_CONTAINS(err1.GetDetail(), "1.25 MB of scratch is currently in use by "
+      "this Impala Daemon (1.25 MB by this query)");
   Status err2 = GroupAllocateSpace(&file_group_2, ALLOC_SIZE, &alloc_file, &offset);
   ASSERT_EQ(err2.code(), TErrorCode::SCRATCH_ALLOCATION_FAILED);
+  EXPECT_STR_CONTAINS(err2.GetDetail(), "Could not create files in any configured "
+      "scratch directories (--scratch_dirs=/tmp/tmp-file-mgr-test.1/impala-scratch,"
+      "/tmp/tmp-file-mgr-test.2/impala-scratch)");
+  EXPECT_STR_CONTAINS(err2.GetDetail(), "1.25 MB of scratch is currently in use by "
+      "this Impala Daemon (0 by this query)");
 
   // A FileGroup should recover once allocations are released, i.e. it does not
   // permanently block allocating files from the group.
diff --git a/be/src/runtime/tmp-file-mgr.cc b/be/src/runtime/tmp-file-mgr.cc
index a27ae2e..b803a55 100644
--- a/be/src/runtime/tmp-file-mgr.cc
+++ b/be/src/runtime/tmp-file-mgr.cc
@@ -566,7 +566,8 @@ Status TmpFileMgr::FileGroup::ScratchAllocationFailedStatus(
   }
   Status status(TErrorCode::SCRATCH_ALLOCATION_FAILED, join(tmp_dir_paths, ","),
       GetBackendString(),
-      PrettyPrinter::PrintBytes(scratch_space_bytes_used_counter_->value()),
+      PrettyPrinter::PrintBytes(
+        tmp_file_mgr_->scratch_bytes_used_metric_->current_value()->GetValue()),
       PrettyPrinter::PrintBytes(current_bytes_allocated_),
       join(at_capacity_dir_paths, ","));
   // Include all previous errors that may have caused the failure.
diff --git a/be/src/util/metrics.h b/be/src/util/metrics.h
index 68f213f..c2c895e 100644
--- a/be/src/util/metrics.h
+++ b/be/src/util/metrics.h
@@ -274,6 +274,8 @@ class AtomicHighWaterMarkGauge : public ScalarMetric<int64_t, TMetricKind::GAUGE
     UpdateMax(new_val);
   }
 
+  IntGauge* current_value() const { return current_value_; }
+
  private:
   FRIEND_TEST(MetricsTest, AtomicHighWaterMarkGauge);
   friend class TmpFileMgrTest;