mirror of
https://github.com/apache/impala.git
synced 2025-12-19 18:12:08 -05:00
IMPALA-8299: Fix crash in GroupingAggregator on uninited hash table
If HashTable::Init() fails, in some cases we may try to call HashTable::Close() on the table in GroupingAggregator::Close(), which can cause a crash. The solution is to set the hash table to a nullptr if Init() fails. I also verified that the other use of HashTable, PhjBuilder, handles this case correctly. Testing: - Manually verified that the crash no longer occurs if HashTable::Init fails. Change-Id: I381657c43f93eb4871b93d54532cb886198fd0b2 Reviewed-on: http://gerrit.cloudera.org:8080/12746 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Gabor Kaszab
parent
e8c6adcc2b
commit
030c445ac9
@@ -89,7 +89,12 @@ Status GroupingAggregator::Partition::InitHashTable(bool* got_memory) {
|
|||||||
1L << (32 - NUM_PARTITIONING_BITS), PAGG_DEFAULT_HASH_TABLE_SZ));
|
1L << (32 - NUM_PARTITIONING_BITS), PAGG_DEFAULT_HASH_TABLE_SZ));
|
||||||
// Please update the error message in CreateHashPartitions() if initial size of
|
// Please update the error message in CreateHashPartitions() if initial size of
|
||||||
// hash table changes.
|
// hash table changes.
|
||||||
return hash_tbl->Init(got_memory);
|
Status status = hash_tbl->Init(got_memory);
|
||||||
|
if (!status.ok() || !(*got_memory)) {
|
||||||
|
hash_tbl->Close();
|
||||||
|
hash_tbl.reset();
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status GroupingAggregator::Partition::SerializeStreamForSpilling() {
|
Status GroupingAggregator::Partition::SerializeStreamForSpilling() {
|
||||||
|
|||||||
@@ -346,6 +346,8 @@ class GroupingAggregator : public Aggregator {
|
|||||||
|
|
||||||
/// Initializes the hash table. 'aggregated_row_stream' must be non-NULL.
|
/// Initializes the hash table. 'aggregated_row_stream' must be non-NULL.
|
||||||
/// Sets 'got_memory' to true if the hash table was initialised or false on OOM.
|
/// Sets 'got_memory' to true if the hash table was initialised or false on OOM.
|
||||||
|
/// After returning, 'hash_tbl' will be non-null iff 'got_memory' is true and the
|
||||||
|
/// returned status is OK.
|
||||||
Status InitHashTable(bool* got_memory) WARN_UNUSED_RESULT;
|
Status InitHashTable(bool* got_memory) WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/// Called in case we need to serialize aggregated rows. This step effectively does
|
/// Called in case we need to serialize aggregated rows. This step effectively does
|
||||||
|
|||||||
Reference in New Issue
Block a user