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 2020/10/29 16:51:48 UTC

[impala] branch master updated (09fdeb5 -> 1bd27a3)

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

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


    from 09fdeb5  IMPALA-10267: Impala crashes in HdfsScanner::WriteTemplateTuples() with negative num_tuples
     new d62a040  IMPALA-10102 Fix Impalad crashes when writing a parquet file with large rows.
     new 1bd27a3  IMPALA-7097 Print EC info in the query plan and profile

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 be/src/exec/parquet/hdfs-parquet-table-writer.cc   | 22 +++++++++++++---
 .../org/apache/impala/planner/HdfsScanNode.java    | 30 ++++++++++++++++++++--
 2 files changed, 47 insertions(+), 5 deletions(-)


[impala] 01/02: IMPALA-10102 Fix Impalad crashes when writing a parquet file with large rows.

Posted by jo...@apache.org.
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 d62a04078d1e8455716720374dd07dfab1d7dfd1
Author: Yida Wu <wy...@gmail.com>
AuthorDate: Thu Oct 22 19:32:57 2020 -0700

    IMPALA-10102 Fix Impalad crashes when writing a parquet file with
    large rows.
    
    The crash happens when trying to dereference a null pointer
    returned from a failed memory allocation from memory pool.
    
    TryAllocate is used instead of Allocate and null check is added
    for the large memory allocations such as buffer for dictionary
    page and compressed dictionary page. The memory allocation is
    most likely to fail for these large allocations when memory is
    scarce.
    
    This change fixes the crash in this particular code path,
    however in practice, there could still be an OOM issue which
    could lead to the process getting killed by the OS. The change
    doesn't fix the OOM issue, users need to configure the mem_limit
    (start-up option) properly to avoid the OOM crash.
    
    Test:
    Ran a script to redo the test mentioned in the Jira for thirty
    times, no crash happens.
    
    Change-Id: I0dee474cceb0c370278d290eb900c05769b23dec
    Reviewed-on: http://gerrit.cloudera.org:8080/16638
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/exec/parquet/hdfs-parquet-table-writer.cc | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/be/src/exec/parquet/hdfs-parquet-table-writer.cc b/be/src/exec/parquet/hdfs-parquet-table-writer.cc
index 5986402..d33578d 100644
--- a/be/src/exec/parquet/hdfs-parquet-table-writer.cc
+++ b/be/src/exec/parquet/hdfs-parquet-table-writer.cc
@@ -86,6 +86,9 @@ using namespace apache::thrift;
 // the columns and run that function over row batches.
 // TODO: we need to pass in the compression from the FE/metadata
 
+static const string PARQUET_MEM_LIMIT_EXCEEDED =
+    "HdfsParquetTableWriter::$0() failed to allocate $1 bytes for $2.";
+
 namespace impala {
 
 // Base class for column writers. This contains most of the logic except for
@@ -759,8 +762,14 @@ Status HdfsParquetTableWriter::BaseColumnWriter::Flush(int64_t* file_pos,
     header.__set_dictionary_page_header(dict_header);
 
     // Write the dictionary page data, compressing it if necessary.
-    uint8_t* dict_buffer = parent_->per_file_mem_pool_->Allocate(
-        header.uncompressed_page_size);
+    uint8_t* dict_buffer =
+        parent_->per_file_mem_pool_->TryAllocate(header.uncompressed_page_size);
+    if (UNLIKELY(dict_buffer == nullptr)) {
+      string details = (Substitute(PARQUET_MEM_LIMIT_EXCEEDED, "BaseColumnWriter::Flush",
+          header.uncompressed_page_size, "dictionary page"));
+      return parent_->per_file_mem_pool_->mem_tracker()->MemLimitExceeded(
+          parent_->state_, details, header.uncompressed_page_size);
+    }
     dict_encoder_base_->WriteDict(dict_buffer);
     if (compressor_.get() != nullptr) {
       SCOPED_TIMER(parent_->parent_->compress_timer());
@@ -768,7 +777,14 @@ Status HdfsParquetTableWriter::BaseColumnWriter::Flush(int64_t* file_pos,
           compressor_->MaxOutputLen(header.uncompressed_page_size);
       DCHECK_GT(max_compressed_size, 0);
       uint8_t* compressed_data =
-          parent_->per_file_mem_pool_->Allocate(max_compressed_size);
+          parent_->per_file_mem_pool_->TryAllocate(max_compressed_size);
+      if (UNLIKELY(compressed_data == nullptr)) {
+        string details =
+            (Substitute(PARQUET_MEM_LIMIT_EXCEEDED, "BaseColumnWriter::Flush",
+                max_compressed_size, "compressed dictionary page"));
+        return parent_->per_file_mem_pool_->mem_tracker()->MemLimitExceeded(
+            parent_->state_, details, max_compressed_size);
+      }
       header.compressed_page_size = max_compressed_size;
       const Status& status =
           compressor_->ProcessBlock32(true, header.uncompressed_page_size, dict_buffer,


[impala] 02/02: IMPALA-7097 Print EC info in the query plan and profile

Posted by jo...@apache.org.
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 1bd27a3ea87622edc869d3ff72ce9b0881451c95
Author: Qifan Chen <qc...@cloudera.com>
AuthorDate: Mon Oct 12 20:31:31 2020 -0400

    IMPALA-7097 Print EC info in the query plan and profile
    
    This fix added the functionality to show the number of erasure coded
    files and the total size of such files in the scan node in the
    query plan and profile. Shown below are two examples for the HDFS file
    system.
    
    Non-partitioned table:
    00:SCAN HDFS [default.test_show_ec_nonpart, RANDOM]
       HDFS partitions=1/1 files=2 size=1.65KB
       erasure coded: files=2 size=1.65KB
       stored statistics:
    
    Partitioned table:
    00:SCAN HDFS [default.test_show_ec_part]
       HDFS partitions=4/4 files=4 size=2.36KB
       erasure coded: files=3 size=1.77KB
       row-size=12B cardinality=999
    
    Testing:
    1. Unit testing;
    2. Ran Core tests successfully.
    
    Change-Id: I6ea378914624a714fde820d290b3b9c43325c6a1
    Reviewed-on: http://gerrit.cloudera.org:8080/16587
    Reviewed-by: Aman Sinha <am...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 .../org/apache/impala/planner/HdfsScanNode.java    | 30 ++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/planner/HdfsScanNode.java b/fe/src/main/java/org/apache/impala/planner/HdfsScanNode.java
index 4a3cee6..40e3e9e 100644
--- a/fe/src/main/java/org/apache/impala/planner/HdfsScanNode.java
+++ b/fe/src/main/java/org/apache/impala/planner/HdfsScanNode.java
@@ -212,6 +212,10 @@ public class HdfsScanNode extends ScanNode {
   private Map<FileSystemUtil.FsType, Long> totalFilesPerFs_ = new TreeMap<>();
   private Map<FileSystemUtil.FsType, Long> totalBytesPerFs_ = new TreeMap<>();
 
+  // Number of erasure coded files and bytes scanned, groupped by the FsType.
+  private Map<FileSystemUtil.FsType, Long> totalFilesPerFsEC_ = new TreeMap<>();
+  private Map<FileSystemUtil.FsType, Long> totalBytesPerFsEC_ = new TreeMap<>();
+
   // File formats scanned. Set in computeScanRangeLocations().
   private Set<HdfsFileFormat> fileFormats_;
 
@@ -833,6 +837,8 @@ public class HdfsScanNode extends ScanNode {
 
     totalFilesPerFs_ = new TreeMap<>();
     totalBytesPerFs_ = new TreeMap<>();
+    totalFilesPerFsEC_ = new TreeMap<>();
+    totalBytesPerFsEC_ = new TreeMap<>();
     largestScanRangeBytes_ = 0;
     maxScanRangeNumRows_ = -1;
     fileFormats_ = new HashSet<>();
@@ -883,6 +889,7 @@ public class HdfsScanNode extends ScanNode {
       boolean partitionMissingDiskIds = false;
       totalBytesPerFs_.merge(partition.getFsType(), partitionBytes, Long::sum);
       totalFilesPerFs_.merge(partition.getFsType(), (long) fileDescs.size(), Long::sum);
+
       for (FileDescriptor fileDesc: fileDescs) {
         if (!analyzer.getQueryOptions().isAllow_erasure_coded_files() &&
             fileDesc.getIsEc()) {
@@ -890,6 +897,14 @@ public class HdfsScanNode extends ScanNode {
               "Scanning of HDFS erasure-coded file (%s/%s) is not supported",
               partition.getLocation(), fileDesc.getRelativePath()));
         }
+
+        // Accumulate on the number of EC files and the total size of such files.
+        if (fileDesc.getIsEc()) {
+          totalFilesPerFsEC_.merge(partition.getFsType(), 1L, Long::sum);
+          totalBytesPerFsEC_.merge(
+              partition.getFsType(), fileDesc.getFileLength(), Long::sum);
+        }
+
         if (!fsHasBlocks) {
           Preconditions.checkState(fileDesc.getNumFileBlocks() == 0);
           generateScanRangeSpecs(partition, fileDesc, scanRangeBytesLimit);
@@ -1471,6 +1486,7 @@ public class HdfsScanNode extends ScanNode {
               Expr.getExplainString(partitionConjuncts_, detailLevel)));
       }
       String partMetaTemplate = "partitions=%d/%d files=%d size=%s\n";
+      String erasureCodeTemplate = "erasure coded: files=%d size=%s\n";
       if (!numPartitionsPerFs_.isEmpty()) {
         // The table is partitioned; print a line for each filesystem we are reading
         // partitions from
@@ -1482,16 +1498,26 @@ public class HdfsScanNode extends ScanNode {
           output.append(String.format(partMetaTemplate, partsPerFs.getValue(),
               table.getPartitions().size(), totalFilesPerFs_.get(fsType),
               PrintUtils.printBytes(totalBytesPerFs_.get(fsType))));
+
+          // Report the total number of erasure coded files and total bytes, if any.
+          if (totalFilesPerFsEC_.containsKey(fsType)) {
+            long totalNumECFiles = totalFilesPerFsEC_.get(fsType);
+            long totalECSize = totalBytesPerFsEC_.get(fsType);
+            output.append(String.format("%s", detailPrefix))
+                .append(String.format(erasureCodeTemplate, totalNumECFiles,
+                    PrintUtils.printBytes(totalECSize)));
+          }
         }
       } else if (tbl_.getNumClusteringCols() == 0) {
-        // There are no partitions so we use the FsType of the base table
+        // There are no partitions so we use the FsType of the base table. No report
+        // on EC related info.
         output.append(detailPrefix);
         output.append(table.getFsType()).append(" ");
         output.append(String.format(partMetaTemplate, 1, table.getPartitions().size(),
             0, PrintUtils.printBytes(0)));
       } else {
         // The table is partitioned, but no partitions are selected; in this case we
-        // exclude the FsType completely
+        // exclude the FsType completely. No report on EC related info.
         output.append(detailPrefix);
         output.append(String.format(partMetaTemplate, 0, table.getPartitions().size(),
             0, PrintUtils.printBytes(0)));