mirror of
https://github.com/apache/impala.git
synced 2026-01-01 00:00:20 -05:00
FunctionContext::Allocate(), FunctionContextImpl::AllocateLocal() and FunctionContext::Reallocate() allocate memory without taking memory limits into account. The problem is that these functions invoke FreePool::Allocate() which may call MemPool::Allocate() that doesn't check against the memory limits. This patch fixes the problem by making these FunctionContext functions check for memory limits and set an error in the FunctionContext object if memory limits are exceeded. An alternative would be for these functions to call MemPool::TryAllocate() instead and return NULL if memory limits are exceeded. However, this may break some existing external UDAs which don't check for allocation failures, leading to unexpected crashes of Impala. Therefore, we stick with this ad hoc approach until the UDF/UDA interfaces are updated in the future releases. Callers of these FunctionContext functions are also updated to handle potential failed allocations instead of operating on NULL pointers. The query status will be polled at various locations and terminate the query. This patch also fixes MemPool to handle the case in which malloc may return NULL. It propagates the failure to the callers instead of continuing to run with NULL pointers. In addition, errors during aggregate functions' initialization are now properly propagated. Change-Id: Icefda795cd685e5d0d8a518cbadd37f02ea5e733 Reviewed-on: http://gerrit.cloudera.org:8080/1445 Reviewed-by: Michael Ho <kwho@cloudera.com> Tested-by: Internal Jenkins
118 lines
5.7 KiB
Plaintext
118 lines
5.7 KiB
Plaintext
====
|
|
---- QUERY
|
|
# IMPALA-1619 group_concat() error
|
|
select length(group_concat(l_comment, "!")) from (
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem) a
|
|
---- CATCH
|
|
Concatenated string length larger than allowed limit of 1 GB character data
|
|
=====
|
|
---- QUERY
|
|
# IMPALA-2620: Allocation by UDF/UDA need to take into account of memory limit.
|
|
SET mem_limit=512m;
|
|
select length(group_concat(l_comment, "!")) from (
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem union all
|
|
select l_comment from tpch_parquet.lineitem) a
|
|
---- CATCH
|
|
Memory limit exceeded
|
|
====
|
|
---- QUERY
|
|
set mem_limit=0
|
|
====
|