Skip to content

Commit

Permalink
HIVE-1908 FileHandler leak on partial iteration of the resultset
Browse files Browse the repository at this point in the history
(Chinna Rao Lalam via namit)



git-svn-id: https://svn.apache.org/repos/asf/hive/trunk@1063062 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Namit Jain committed Jan 24, 2011
1 parent 47468bf commit b9260ff
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ Trunk - Unreleased
HIVE-1897 Alter command execution "when HDFS is down" results in holding
stale data in MetaStore (Chinna Rao Lalam via namit)

HIVE-1908 FileHandler leak on partial iteration of the resultset
(Chinna Rao Lalam via namit)

TESTS

HIVE-1464. improve test query performance
Expand Down
18 changes: 18 additions & 0 deletions ql/src/java/org/apache/hadoop/hive/ql/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.common.JavaUtils;
import org.apache.hadoop.hive.conf.HiveConf;
Expand Down Expand Up @@ -1130,9 +1131,26 @@ public boolean getResults(ArrayList<String> res) throws IOException {

public int close() {
try {
if (plan != null) {
FetchTask fetchTask = plan.getFetchTask();
if (null != fetchTask) {
try {
fetchTask.clearFetch();
} catch (Exception e) {
LOG.debug(" Exception while clearing the Fetch task ", e);
}
}
}
if (ctx != null) {
ctx.clear();
}
if (null != resStream) {
try {
((FSDataInputStream) resStream).close();
} catch (Exception e) {
LOG.debug(" Exception while closing the resStream ", e);
}
}
} catch (Exception e) {
console.printError("FAILED: Hive Internal Error: " + Utilities.getNameMessage(e) + "\n"
+ org.apache.hadoop.util.StringUtils.stringifyException(e));
Expand Down
20 changes: 17 additions & 3 deletions ql/src/java/org/apache/hadoop/hive/ql/exec/FetchTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
import org.apache.hadoop.hive.ql.Context;
import org.apache.hadoop.hive.ql.DriverContext;
import org.apache.hadoop.hive.ql.QueryPlan;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.plan.FetchWork;
import org.apache.hadoop.hive.ql.plan.TableDesc;
import org.apache.hadoop.hive.ql.plan.api.StageType;
import org.apache.hadoop.hive.serde.Constants;
import org.apache.hadoop.hive.serde2.DelimitedJSONSerDe;
import org.apache.hadoop.hive.serde2.objectinspector.InspectableObject;
import org.apache.hadoop.hive.serde2.SerDe;
import org.apache.hadoop.hive.serde2.objectinspector.InspectableObject;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.util.ReflectionUtils;
Expand Down Expand Up @@ -163,11 +164,24 @@ public String getName() {
@Override
protected void localizeMRTmpFilesImpl(Context ctx) {
String s = work.getTblDir();
if ((s != null) && ctx.isMRTmpFileURI(s))
if ((s != null) && ctx.isMRTmpFileURI(s)) {
work.setTblDir(ctx.localizeMRTmpFileURI(s));
}

ArrayList<String> ls = work.getPartDir();
if (ls != null)
if (ls != null) {
ctx.localizePaths(ls);
}
}

/**
* Clear the Fetch Operator.
*
* @throws HiveException
*/
public void clearFetch() throws HiveException {
if (null != ftOp) {
ftOp.clearFetchContext();
}
}
}

0 comments on commit b9260ff

Please sign in to comment.