You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pv...@apache.org on 2021/04/19 08:56:45 UTC

[hive] branch branch-3.1 updated: HIVE-24851: Fix reader leak in AvroGenericRecordReader ( Lukasz Osipiuk reviewed by Peter Vary)

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

pvary pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new a93798f  HIVE-24851: Fix reader leak in AvroGenericRecordReader ( Lukasz Osipiuk reviewed by Peter Vary)
a93798f is described below

commit a93798f40a81506f2b0fdee224465d432161a0e0
Author: Ɓukasz Osipiuk <lu...@osipiuk.net>
AuthorDate: Mon Apr 19 09:56:25 2021 +0100

    HIVE-24851: Fix reader leak in AvroGenericRecordReader ( Lukasz Osipiuk reviewed by Peter Vary)
    
    Closes (#2040)
---
 .../hive/ql/io/avro/AvroGenericRecordReader.java   | 36 ++++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/avro/AvroGenericRecordReader.java b/ql/src/java/org/apache/hadoop/hive/ql/io/avro/AvroGenericRecordReader.java
index 485337e..8944eac 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/avro/AvroGenericRecordReader.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/avro/AvroGenericRecordReader.java
@@ -87,20 +87,36 @@ public class AvroGenericRecordReader implements
     }
 
     if (split.getLength() == 0) {
-      this.isEmptyInput = true;
-      this.start = 0;
       this.reader = null;
-    }
-    else {
-      this.isEmptyInput = false;
+      this.isEmptyInput = true;
+    } else {
       this.reader = new DataFileReader<GenericRecord>(new FsInput(split.getPath(), job), gdr);
-      this.reader.sync(split.getStart());
-      this.start = reader.tell();
+      this.isEmptyInput = false;
     }
-    this.stop = split.getStart() + split.getLength();
-    this.recordReaderID = new UID();
 
-    this.writerTimezone = extractWriterTimezoneFromMetadata(job, split, gdr);
+    try {
+      if (this.isEmptyInput) {
+        this.start = 0;
+      } else {
+        this.reader.sync(split.getStart());
+        this.start = reader.tell();
+      }
+      this.stop = split.getStart() + split.getLength();
+      this.recordReaderID = new UID();
+
+      this.writerTimezone = extractWriterTimezoneFromMetadata(job, split, gdr);
+    } catch (Exception e) {
+      if (this.reader != null) {
+        try {
+          this.reader.close();
+        } catch (Exception closeException) {
+          if (closeException != e) {
+            e.addSuppressed(closeException);
+          }
+        }
+      }
+      throw e;
+    }
   }
 
   /**