This is an automated email from the ASF dual-hosted git repository.
ayushtkn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new c343179a013 HIVE-29632: hive.fetch.task.caching=true (default) causes
unbounded heap allocation thus crashing HiveServer2 with OutOfMemoryError
(#6510)
c343179a013 is described below
commit c343179a0131947e8ae80d6d69ba75a0c525ac30
Author: Vikram Ahuja <[email protected]>
AuthorDate: Mon Jul 27 20:39:27 2026 +0530
HIVE-29632: hive.fetch.task.caching=true (default) causes unbounded heap
allocation thus crashing HiveServer2 with OutOfMemoryError (#6510)
---
cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java | 4 +++-
.../apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java | 11 +++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
b/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
index 2ac3d425b70..07b063b28ff 100644
--- a/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
+++ b/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
@@ -295,7 +295,9 @@ CommandProcessorResponse processLocalCmd(String cmd,
CommandProcessor proc, CliS
console.printError("Failed with exception " + e.getClass().getName()
+ ":" + e.getMessage(),
"\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
throw new CommandProcessorException(1);
- } finally {
+ } catch (RuntimeException e) {
+ throw new CommandProcessorException(1);
+ } finally {
qp.close();
ShimLoader.getHadoopShims()
.setHadoopSessionContext(String.format(USER_ID,
ss.getSessionId(), ss.getUserName()));
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java
index dae7fa6eefa..67f8a30d282 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java
@@ -61,6 +61,7 @@
import org.apache.hadoop.hive.ql.exec.TaskFactory;
import org.apache.hadoop.hive.ql.exec.Utilities;
import org.apache.hadoop.hive.ql.hooks.ReadEntity;
+import org.apache.hadoop.hive.ql.io.AcidUtils;
import org.apache.hadoop.hive.ql.io.ContentSummaryInputFormat;
import org.apache.hadoop.hive.ql.io.HiveInputFormat;
import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -148,8 +149,14 @@ private FetchTask optimize(ParseContext pctx, String
alias, TableScanOperator so
if (fetch != null && checkThreshold(fetch, limit, pctx)) {
FetchWork fetchWork = fetch.convertToWork();
FetchTask fetchTask = (FetchTask) TaskFactory.get(fetchWork);
- fetchTask.setCachingEnabled(HiveConf.getBoolVar(pctx.getConf(),
- HiveConf.ConfVars.HIVE_FETCH_TASK_CACHING));
+ boolean cachingEnabled = HiveConf.getBoolVar(pctx.getConf(),
+ HiveConf.ConfVars.HIVE_FETCH_TASK_CACHING);
+ if (cachingEnabled && !AcidUtils.isTransactionalTable(fetch.table)) {
+ LOG.debug("Fetch task caching is enabled but table {} is not
transactional. " +
+ "Caching is only supported for ACID tables. Disabling.",
fetch.table.getCompleteName());
+ cachingEnabled = false;
+ }
+ fetchTask.setCachingEnabled(cachingEnabled);
fetchWork.setSink(fetch.completed(pctx, fetchWork));
fetchWork.setSource(source);
fetchWork.setLimit(limit);