[jira] [Commented] (DRILL-8479) mergejion memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810231#comment-17810231 ] ASF GitHub Bot commented on DRILL-8479: --- shfshihuafeng opened a new pull request, #2878: URL: https://github.com/apache/drill/pull/2878 … (#2876) # [DRILL-8479](https://issues.apache.org/jira/browse/DRILL-8479): mergejoin leak when Depleting incoming batches throw exception ## Description when fragment failed, it call close() from MergeJoinBatch. but if leftIterator.close() throw exception, we could not call rightIterator.close() to release memory。 ## Documentation (Please describe user-visible changes similar to what should appear in the Drill documentation.) ## Testing The test method is the same with link, only one parameter needs to be modified, set planner.enable_hashjoin =false to ensure use mergejoin operator [](https://github.com/apache/drill/pull/2875) > mergejion memory leak when exception > - > > Key: DRILL-8479 > URL: https://issues.apache.org/jira/browse/DRILL-8479 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Critical > Attachments: 0001-mergejoin-leak.patch > > > *Describe the bug* > megerjoin leak when RecordIterator allocate memory exception with > OutOfMemoryException{*}{*} > {*}Steps to reproduce the behavior{*}: > # prepare data for tpch 1s > # set direct memory 5g > # set planner.enable_hashjoin =false to ensure use mergejoin operator。 > # set drill.memory.debug.allocator =true (Check for memory leaks ) > # 20 concurrent for tpch sql8 > # when it had OutOfMemoryException or null EXCEPTION , stopped all sql. > # finding memory leak > *Expected behavior* > when all sql sop , we should find direct memory is 0 AND could not > find leak log like following. > {code:java} > Allocator(op:2:0:11:MergeJoinPOP) 100/73728/4874240/100 > (res/actual/peak/limit){code} > *Error detail, log output or screenshots* > {code:java} > Unable to allocate buffer of size XX (rounded from XX) due to memory limit > (). Current allocation: xx{code} > [^0001-mergejoin-leak.patch] > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_nationkey = n2.n_nationkey and o_orderdate between date > '1995-01-01' and date '1996-12-31' and p_type = 'LARGE BRUSHED BRASS') as > all_nations group by o_year order by o_year > {code} > > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (DRILL-8479) mergejion memory leak when exception
shihuafeng created DRILL-8479: - Summary: mergejion memory leak when exception Key: DRILL-8479 URL: https://issues.apache.org/jira/browse/DRILL-8479 Project: Apache Drill Issue Type: Bug Components: Execution - Relational Operators Affects Versions: 1.21.1 Reporter: shihuafeng Attachments: 0001-mergejoin-leak.patch *Describe the bug* megerjoin leak when RecordIterator allocate memory exception with OutOfMemoryException{*}{*} {*}Steps to reproduce the behavior{*}: # prepare data for tpch 1s # set direct memory 5g # set planner.enable_hashjoin =false to ensure use mergejoin operator。 # set drill.memory.debug.allocator =true (Check for memory leaks ) # 20 concurrent for tpch sql8 # when it had OutOfMemoryException or null EXCEPTION , stopped all sql. # finding memory leak *Expected behavior* when all sql sop , we should find direct memory is 0 AND could not find leak log like following. {code:java} Allocator(op:2:0:11:MergeJoinPOP) 100/73728/4874240/100 (res/actual/peak/limit){code} *Error detail, log output or screenshots* {code:java} Unable to allocate buffer of size XX (rounded from XX) due to memory limit (). Current allocation: xx{code} [^0001-mergejoin-leak.patch] sql {code:java} // code placeholder select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / sum(volume) as mkt_share from ( select extract(year from o_orderdate) as o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = 'ASIA' and s_nationkey = n2.n_nationkey and o_orderdate between date '1995-01-01' and date '1996-12-31' and p_type = 'LARGE BRUSHED BRASS') as all_nations group by o_year order by o_year {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810171#comment-17810171 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1464222619 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/AbstractHashBinaryRecordBatch.java: ## @@ -1312,7 +1312,9 @@ private void cleanup() { } // clean (and deallocate) each partition, and delete its spill file for (HashPartition partn : partitions) { - partn.close(); + if (partn != null) { +partn.close(); + } Review Comment: (partn != null) are necessary ,see Comment above on 1. fix idea > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_nationkey = n2.n_nationkey and o_orderdate between date > '1995-01-01' and date '1996-12-31' and p_type = 'LARGE BRUSHED BRASS') as > all_nations group by o_year order by o_year > {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810170#comment-17810170 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1464211148 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/common/HashPartition.java: ## @@ -157,11 +162,11 @@ public HashPartition(FragmentContext context, BufferAllocator allocator, Chained .build(logger); } catch (SchemaChangeException sce) { throw new IllegalStateException("Unexpected Schema Change while creating a hash table",sce); -} -this.hjHelper = semiJoin ? null : new HashJoinHelper(context, allocator); -tmpBatchesList = new ArrayList<>(); -if (numPartitions > 1) { - allocateNewCurrentBatchAndHV(); +} catch (OutOfMemoryException oom) { + close(); Review Comment: ### 1. fix idea The design is any operator fails, the entire operator stack is closed. but partitions is array which is initialed by null。if hashPartition object is not created successfully, it throw exception. so partitions array data after index which is null。 ` for (int part = 0; part < numPartitions; part++) { partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); }` for example partitions array length is 32, numPartitions =32 when numPartitions =10 ,throw except. partitions[11-31] will be null object which index numPartitions =10 was created failed ,but it had allocater memory. when calling close() , hashpartion object which numPartitions =10 can not call close,beacause it is null。 ### 2. another fix idea we do not throw exception and do not call close, but catch. we can create hash partiotn object . thus when calling close() , we can release。 ``` //1. add isException parameter when construct HashPartition object HashPartition(FragmentContext context, BufferAllocator allocator, ChainedHashTable baseHashTable, RecordBatch buildBatch, RecordBatch probeBatch, boolean semiJoin, int recordsPerBatch, SpillSet spillSet, int partNum, int cycleNum, int numPartitions , boolean **isException** ) //2. catch except to ensure HashPartition object has been created } catch (OutOfMemoryException oom) { //do not call close ,do not throw except isException =true; } //3.deal with exception AbstractHashBinaryRecordBatch#initializeBuild boolean isException = false; try { for (int part = 0; part < numPartitions; part++) { if (isException) { break; } partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions,**isException** ); } } catch (Exception e) { isException = true; } if (isException ){ throw UserException.memoryError(exceptions[0]) .message("Failed to allocate hash partition.") .build(logger); } ``` > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810168#comment-17810168 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1464211148 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/common/HashPartition.java: ## @@ -157,11 +162,11 @@ public HashPartition(FragmentContext context, BufferAllocator allocator, Chained .build(logger); } catch (SchemaChangeException sce) { throw new IllegalStateException("Unexpected Schema Change while creating a hash table",sce); -} -this.hjHelper = semiJoin ? null : new HashJoinHelper(context, allocator); -tmpBatchesList = new ArrayList<>(); -if (numPartitions > 1) { - allocateNewCurrentBatchAndHV(); +} catch (OutOfMemoryException oom) { + close(); Review Comment: ### 1. fix idea The design is any operator fails, the entire operator stack is closed. but partitions is array which is initialed by null。if hashPartition object is not created successfully, it throw exception. so partitions array data after index which is null。 ` for (int part = 0; part < numPartitions; part++) { partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); }` for example partitions array length is 32, numPartitions =32 when numPartitions =10 ,throw except. partitions[11-31] will be null object which index numPartitions =10 was created failed ,but it had allocater memory. when calling close() , hashpartion object which numPartitions =10 can not call close,beacause it is null。 ### 2. another fix idea we do not throw exception and do not call close, but catch. we can create hash partiotn object . thus when calling close() , we can release。 ``` //add isException parameter when construct HashPartition object HashPartition(FragmentContext context, BufferAllocator allocator, ChainedHashTable baseHashTable, RecordBatch buildBatch, RecordBatch probeBatch, boolean semiJoin, int recordsPerBatch, SpillSet spillSet, int partNum, int cycleNum, int numPartitions , boolean **isException** ) } catch (OutOfMemoryException oom) { //do not call close ,do not throw except isException =true; } AbstractHashBinaryRecordBatch#initializeBuild boolean isException = false; try { for (int part = 0; part < numPartitions; part++) { if (isException) { break; } partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions,**isException** ); } } catch (Exception e) { isException = true; } if (isException ){ throw UserException.memoryError(exceptions[0]) .message("Failed to allocate hash partition.") .build(logger); } ``` > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpc
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810167#comment-17810167 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1464211148 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/common/HashPartition.java: ## @@ -157,11 +162,11 @@ public HashPartition(FragmentContext context, BufferAllocator allocator, Chained .build(logger); } catch (SchemaChangeException sce) { throw new IllegalStateException("Unexpected Schema Change while creating a hash table",sce); -} -this.hjHelper = semiJoin ? null : new HashJoinHelper(context, allocator); -tmpBatchesList = new ArrayList<>(); -if (numPartitions > 1) { - allocateNewCurrentBatchAndHV(); +} catch (OutOfMemoryException oom) { + close(); Review Comment: ### 1. fix idea The design is any operator fails, the entire operator stack is closed. but partitions is array which is initialed by null。if hashPartition object is not created successfully, it throw exception. so partitions array data after index which is null。 ` for (int part = 0; part < numPartitions; part++) { partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); }` for example partitions array length is 32, numPartitions =32 when numPartitions =10 ,throw except. partitions[11-31] will be null object which index numPartitions =10 was created failed ,but it had allocater memory. when calling close() , hashpartion object which numPartitions =10 can not call close,beacause it is null。 ### 2. another fix idea we do not throw exception and do not call close, but catch. we can create hash partiotn object . thus when calling close() , we can release。 but if ``` //add isException parameter when construct HashPartition object HashPartition(FragmentContext context, BufferAllocator allocator, ChainedHashTable baseHashTable, RecordBatch buildBatch, RecordBatch probeBatch, boolean semiJoin, int recordsPerBatch, SpillSet spillSet, int partNum, int cycleNum, int numPartitions , boolean **isException** ) } catch (OutOfMemoryException oom) { //do not call close ,do not throw except isException =true; } AbstractHashBinaryRecordBatch#initializeBuild boolean isException = false; try { for (int part = 0; part < numPartitions; part++) { if (isException) { break; } partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions,**isException** ); } } catch (Exception e) { isException = true; } if (isException ){ throw UserException.memoryError(exceptions[0]) .message("Failed to allocate hash partition.") .build(logger); } ``` > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem,
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810166#comment-17810166 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1464211148 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/common/HashPartition.java: ## @@ -157,11 +162,11 @@ public HashPartition(FragmentContext context, BufferAllocator allocator, Chained .build(logger); } catch (SchemaChangeException sce) { throw new IllegalStateException("Unexpected Schema Change while creating a hash table",sce); -} -this.hjHelper = semiJoin ? null : new HashJoinHelper(context, allocator); -tmpBatchesList = new ArrayList<>(); -if (numPartitions > 1) { - allocateNewCurrentBatchAndHV(); +} catch (OutOfMemoryException oom) { + close(); Review Comment: ### 1. fix idea The design is any operator fails, the entire operator stack is closed. but partitions is array which is initialed by null。if hashPartition object is not created successfully, it throw exception. so partitions array data after index which is null。 ` for (int part = 0; part < numPartitions; part++) { partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); }` for example partitions array length is 32, numPartitions =32 when numPartitions =10 ,throw except. partitions[11-31] will be null object which index numPartitions =10 was created failed ,but it had allocater memory. when calling close() , hashpartion object which numPartitions =10 can not call close,beacause it is null。 ### 2. another fix idea we do not throw exception and do not call close, but catch. we can create hash partiotn object . thus when calling close() , we can release。 but if ``` HashPartition(FragmentContext context, BufferAllocator allocator, ChainedHashTable baseHashTable, RecordBatch buildBatch, RecordBatch probeBatch, boolean semiJoin, int recordsPerBatch, SpillSet spillSet, int partNum, int cycleNum, int numPartitions , boolean **isException** ) } catch (OutOfMemoryException oom) { //do not call close ,do not throw except isException =false; } AbstractHashBinaryRecordBatch#initializeBuild boolean isException = false; try { for (int part = 0; part < numPartitions; part++) { if (isException) { break; } partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions,**isException** ); } } catch (Exception e) { isException = true; } if (isException ){ throw UserException.memoryError(exceptions[0]) .message("Failed to allocate hash partition.") .build(logger); } ``` > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, >
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810162#comment-17810162 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1464211148 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/common/HashPartition.java: ## @@ -157,11 +162,11 @@ public HashPartition(FragmentContext context, BufferAllocator allocator, Chained .build(logger); } catch (SchemaChangeException sce) { throw new IllegalStateException("Unexpected Schema Change while creating a hash table",sce); -} -this.hjHelper = semiJoin ? null : new HashJoinHelper(context, allocator); -tmpBatchesList = new ArrayList<>(); -if (numPartitions > 1) { - allocateNewCurrentBatchAndHV(); +} catch (OutOfMemoryException oom) { + close(); Review Comment: ### 1. fix idea The design is any operator fails, the entire operator stack is closed. but partitions is array which is initialed by null。if hashPartition object is not created successfully, it throw exception. so partitions array data after index which is null。 ` for (int part = 0; part < numPartitions; part++) { partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); }` for example partitions array length is 32, numPartitions =32 when numPartitions =10 ,throw except. partitions[11-31] will be null object which index numPartitions =10 was created failed ,but it had allocater memory. when calling close() , hashpartion object which numPartitions =10 can not call close,beacause it is null。 ### 2. another fix idea we do not throw exception and do not call close, but catch. we can create hash partiotn object . thus when calling close() , we can release。 but if ``` } catch (OutOfMemoryException oom) { //do not call close ,only throw except throw UserException.memoryError(oom) .message("Failed to allocate hash partition.") .build(logger); } AbstractHashBinaryRecordBatch#initializeBuild boolean isException = false; try { for (int part = 0; part < numPartitions; part++) { if (isException) { break; } partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); } } catch (Exception e) { isException = true; } if (isException ){ throw UserException.memoryError(exceptions[0]) .message("Failed to allocate hash partition.") .build(logger); } ``` > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_na
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810161#comment-17810161 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1464211148 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/common/HashPartition.java: ## @@ -157,11 +162,11 @@ public HashPartition(FragmentContext context, BufferAllocator allocator, Chained .build(logger); } catch (SchemaChangeException sce) { throw new IllegalStateException("Unexpected Schema Change while creating a hash table",sce); -} -this.hjHelper = semiJoin ? null : new HashJoinHelper(context, allocator); -tmpBatchesList = new ArrayList<>(); -if (numPartitions > 1) { - allocateNewCurrentBatchAndHV(); +} catch (OutOfMemoryException oom) { + close(); Review Comment: ### 1. fix idea The design is any operator fails, the entire operator stack is closed. but partitions is array which is initialed by null。if hashPartition object is not created successfully, it throw exception. so partitions array data after index which is null。 ` for (int part = 0; part < numPartitions; part++) { partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); }` for example partitions array length is 32, numPartitions =32 when numPartitions =10 ,throw except. partitions[11-31] will be null object which index numPartitions =10 was created failed ,but it had allocater memory. when calling close() , hashpartion object which numPartitions =10 can not call close,beacause it is null。 2. another fix idea we do not throw exception and do not call close, but catch. we can create hash partiotn object . thus when calling close() , we can release。 but if ``` } catch (OutOfMemoryException oom) { //do not call close ,only throw except throw UserException.memoryError(oom) .message("Failed to allocate hash partition.") .build(logger); } AbstractHashBinaryRecordBatch#initializeBuild boolean isException = false; try { for (int part = 0; part < numPartitions; part++) { if (isException) { break; } partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions); } } catch (Exception e) { isException = true; } if (isException ){ throw UserException.memoryError(exceptions[0]) .message("Failed to allocate hash partition.") .build(logger); } ``` > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_nation
[jira] [Commented] (DRILL-8474) Add Daffodil Format Plugin
[ https://issues.apache.org/jira/browse/DRILL-8474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810092#comment-17810092 ] ASF GitHub Bot commented on DRILL-8474: --- mbeckerle commented on PR #2836: URL: https://github.com/apache/drill/pull/2836#issuecomment-1906827568 Ok, so the geo-ip UDF stuff has no special mechanisms or description about those resource files, so the generic code that "scans" must find them and drag them along automatically. That's the behavior I want. What is "Drill's 3rd Party Jar folder"? If a magic folder just gets dragged over to all nodes, and drill uses a class loader that arranges for jars in that folder to be searched, then there is very little to do, since a DFDL schema can be just a set of jar files containing related resources, and the classes for Daffodil's own UDFs and layers which are java code extensions of its own kind. > Add Daffodil Format Plugin > -- > > Key: DRILL-8474 > URL: https://issues.apache.org/jira/browse/DRILL-8474 > Project: Apache Drill > Issue Type: New Feature >Affects Versions: 1.21.1 >Reporter: Charles Givre >Priority: Major > Fix For: 1.22.0 > > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810091#comment-17810091 ] ASF GitHub Bot commented on DRILL-8478: --- paul-rogers commented on code in PR #2875: URL: https://github.com/apache/drill/pull/2875#discussion_r1463921977 ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/AbstractHashBinaryRecordBatch.java: ## @@ -1312,7 +1312,9 @@ private void cleanup() { } // clean (and deallocate) each partition, and delete its spill file for (HashPartition partn : partitions) { - partn.close(); + if (partn != null) { +partn.close(); + } Review Comment: The above is OK as a work-around. I wonder, however, where the code added a null pointer to the partition list. That should never happen. If it does, it should be fixed at the point where the null pointer is added to the list. Fixing it here is incomplete: there are other places where we loop through the list, and those will also fail. ## exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/common/HashPartition.java: ## @@ -157,11 +162,11 @@ public HashPartition(FragmentContext context, BufferAllocator allocator, Chained .build(logger); } catch (SchemaChangeException sce) { throw new IllegalStateException("Unexpected Schema Change while creating a hash table",sce); -} -this.hjHelper = semiJoin ? null : new HashJoinHelper(context, allocator); -tmpBatchesList = new ArrayList<>(); -if (numPartitions > 1) { - allocateNewCurrentBatchAndHV(); +} catch (OutOfMemoryException oom) { + close(); Review Comment: This call is _probably_ fine. However, the design is that if any operator fails, the entire operator stack is closed. So, `close()` should be called by the fragment executor. There is probably no harm in calling `close()` here, as long as the `close()` method is safe to call twice. If the fragment executor _does not_ call close when the failure occurs during setup, then there is a bug since failing to call `close()` results in just this kind of error. > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_nationkey = n2.n_nationkey and o_orderdate between date > '1995-01-01' and date '1996-12-31' and p_type = 'LARGE BRUSHED BRASS') as > all_nations group by o_year order by o_year > {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8474) Add Daffodil Format Plugin
[ https://issues.apache.org/jira/browse/DRILL-8474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810070#comment-17810070 ] ASF GitHub Bot commented on DRILL-8474: --- cgivre commented on PR #2836: URL: https://github.com/apache/drill/pull/2836#issuecomment-1906689793 > > > @cgivre @paul-rogers is there an example of a Drill UDF that is not part of the drill repository tree? > > > I'd like to understand the mechanisms for distributing any jar files and dependencies of the UDF that drill uses. I can't find any such in the quasi-USFs that are in the Drill tree, because well, since they are part of Drill, and so are their dependencies, this problem doesn't exist. > > > > > > @mbeckerle Here's an example: https://github.com/datadistillr/drill-humanname-functions. I'm sorry we weren't able to connect last week. > > If I understand this correctly, if a jar is on the classpath and has drill-module.conf in its root dir, then drill will find it and read that HOCON file to get the package to add to drill.classpath.scanning.packages. I believe that is correct. > > Drill then appears to scan jars for class files for those packages. Not sure what it is doing with the class files. I imagine it is repackaging them somehow so Drill can use them on the drill distributed nodes. But it isn't yet clear to me how this aspect works. Do these classes just get loaded on the distributed drill nodes? Or is the classpath augmented in some way on the drill nodes so that they see a jar that contains all these classes? > > I have two questions: > > (1) what about dependencies? The UDF may depend on libraries which depend on other libraries, etc. So UDFs are a bit of a special case, but if they do have dependencies, you have to also include those JAR files in the UDF directory, or in Drill's 3rd party JAR folder. I'm not that good with maven, but I've often wondered about making a so-called fat-JAR which includes the dependencies as part of the UDF JAR file. > > (2) what about non-class files, e.g., things under src/main/resources of the project that go into the jar, but aren't "class" files? How do those things also get moved? How would code running in the drill node access these? The usual method is to call getResource(URL) with a URL that gives the path within a jar file to the resource in question. Take a look at this UDF. https://github.com/datadistillr/drill-geoip-functions This UDF has a few external resources including a CSV file and the MaxMind databases. > > Thanks for any info. > Add Daffodil Format Plugin > -- > > Key: DRILL-8474 > URL: https://issues.apache.org/jira/browse/DRILL-8474 > Project: Apache Drill > Issue Type: New Feature >Affects Versions: 1.21.1 >Reporter: Charles Givre >Priority: Major > Fix For: 1.22.0 > > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8474) Add Daffodil Format Plugin
[ https://issues.apache.org/jira/browse/DRILL-8474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17810051#comment-17810051 ] ASF GitHub Bot commented on DRILL-8474: --- mbeckerle commented on PR #2836: URL: https://github.com/apache/drill/pull/2836#issuecomment-1906561549 > > @cgivre @paul-rogers is there an example of a Drill UDF that is not part of the drill repository tree? > > I'd like to understand the mechanisms for distributing any jar files and dependencies of the UDF that drill uses. I can't find any such in the quasi-USFs that are in the Drill tree, because well, since they are part of Drill, and so are their dependencies, this problem doesn't exist. > > @mbeckerle Here's an example: https://github.com/datadistillr/drill-humanname-functions. I'm sorry we weren't able to connect last week. If I understand this correctly, if a jar is on the classpath and has drill-module.conf in its root dir, then drill will find it and read that HOCON file to get the package to add to drill.classpath.scanning.packages. Drill then appears to scan jars for class files for those packages. Not sure what it is doing with the class files. I imagine it is repackaging them somehow so Drill can use them on the drill distributed nodes. But it isn't yet clear to me how this aspect works. Do these classes just get loaded on the distributed drill nodes? Or is the classpath augmented in some way on the drill nodes so that they see a jar that contains all these classes? I have two questions: (1) what about dependencies? The UDF may depend on libraries which depend on other libraries, etc. (2) what about non-class files, e.g., things under src/main/resources of the project that go into the jar, but aren't "class" files? How do those things also get moved? How would code running in the drill node access these? The usual method is to call getResource(URL) with a URL that gives the path within a jar file to the resource in question. Thanks for any info. > Add Daffodil Format Plugin > -- > > Key: DRILL-8474 > URL: https://issues.apache.org/jira/browse/DRILL-8474 > Project: Apache Drill > Issue Type: New Feature >Affects Versions: 1.21.1 >Reporter: Charles Givre >Priority: Major > Fix For: 1.22.0 > > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17809982#comment-17809982 ] ASF GitHub Bot commented on DRILL-8478: --- jnturton merged PR #2875: URL: https://github.com/apache/drill/pull/2875 > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_nationkey = n2.n_nationkey and o_orderdate between date > '1995-01-01' and date '1996-12-31' and p_type = 'LARGE BRUSHED BRASS') as > all_nations group by o_year order by o_year > {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17809816#comment-17809816 ] ASF GitHub Bot commented on DRILL-8478: --- shfshihuafeng commented on PR #2875: URL: https://github.com/apache/drill/pull/2875#issuecomment-1905599592 > [An unsued import crept in](https://github.com/apache/drill/actions/runs/7622586264/job/20762475705#step:6:1277), could you remove it please? removed it > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_nationkey = n2.n_nationkey and o_orderdate between date > '1995-01-01' and date '1996-12-31' and p_type = 'LARGE BRUSHED BRASS') as > all_nations group by o_year order by o_year > {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (DRILL-8478) HashPartition memory leak when exception
[ https://issues.apache.org/jira/browse/DRILL-8478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17809814#comment-17809814 ] ASF GitHub Bot commented on DRILL-8478: --- jnturton commented on PR #2875: URL: https://github.com/apache/drill/pull/2875#issuecomment-1905598192 [An unsued import crept in](https://github.com/apache/drill/actions/runs/7622586264/job/20762475705#step:6:1277), could you remove it please? > HashPartition memory leak when exception > - > > Key: DRILL-8478 > URL: https://issues.apache.org/jira/browse/DRILL-8478 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Relational Operators >Affects Versions: 1.21.1 >Reporter: shihuafeng >Priority: Major > Fix For: 1.21.2 > > Attachments: > 0001-DRILL-8478.-HashPartition-memory-leak-when-it-alloca.patch > > > *Describe the bug* > hashpartition leak when allocate memory exception with OutOfMemoryException > *To Reproduce* > Steps to reproduce the behavior: > # prepare data for tpch 1s > # 20 concurrent for tpch sql8 > # set direct memory 5g > # when it had OutOfMemoryException , stopped all sql. > # finding memory leak > *Expected behavior* > (1)i set \{DRILL_MAX_DIRECT_MEMORY:-"5G"} > (2) i run sql8 (sql detail as Additional context) with 20 concurrent > (3) it had OutOfMemoryException when create hashPartion > *Error detail, log output or screenshots* > Unable to allocate buffer of size 262144 (rounded from 262140) due to memory > limit (41943040). Current allocation: 20447232 > > sql > {code:java} > // code placeholder > select o_year, sum(case when nation = 'CHINA' then volume else 0 end) / > sum(volume) as mkt_share from ( select extract(year from o_orderdate) as > o_year, l_extendedprice * 1.0 as volume, n2.n_name as nation from > hive.tpch1s.part, hive.tpch1s.supplier, hive.tpch1s.lineitem, > hive.tpch1s.orders, hive.tpch1s.customer, hive.tpch1s.nation n1, > hive.tpch1s.nation n2, hive.tpch1s.region where p_partkey = l_partkey and > s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey > and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name > = 'ASIA' and s_nationkey = n2.n_nationkey and o_orderdate between date > '1995-01-01' and date '1996-12-31' and p_type = 'LARGE BRUSHED BRASS') as > all_nations group by o_year order by o_year > {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)