fix hash part infra hang because negative bound size

This commit is contained in:
ls0
2022-03-17 17:57:45 +08:00
committed by LINxiansheng
parent 2ab9fc1911
commit 0e9cb3a0a5
2 changed files with 10 additions and 10 deletions

View File

@ -1062,9 +1062,9 @@ int64_t ObBasicHashPartInfrastructure<HashCol, HashRowStore>::est_bucket_count(
}
int64_t est_bucket_mem_size = next_pow2(rows) * sizeof(void*);
int64_t est_data_mem_size = rows * width;
int64_t max_remain_mem_size = sql_mem_processor_->get_mem_bound() - est_part_cnt_ * BLOCK_SIZE;
int64_t max_remain_mem_size = std::max(0l, sql_mem_processor_->get_mem_bound() - est_part_cnt_ * BLOCK_SIZE);
int64_t est_bucket_num = rows;
while (est_bucket_mem_size + est_data_mem_size > max_remain_mem_size) {
while (est_bucket_mem_size + est_data_mem_size > max_remain_mem_size && est_bucket_num > 0) {
est_bucket_num >>= 1;
est_bucket_mem_size = next_pow2(est_bucket_num) * sizeof(void*);
est_data_mem_size = est_bucket_num * width;
@ -1706,10 +1706,10 @@ int ObPartitionExtendHashTable<Item>::init(
template <typename Item>
int64_t ObPartitionExtendHashTable<Item>::estimate_bucket_num(const int64_t bucket_num, const int64_t max_hash_mem)
{
int64_t max_bound_size = max_hash_mem * MAX_MEM_PERCENT / 100;
int64_t max_bound_size = std::max(0l, max_hash_mem * MAX_MEM_PERCENT / 100);
int64_t est_bucket_num = common::next_pow2(bucket_num);
int64_t est_size = est_bucket_num * sizeof(void*);
while (est_size > max_bound_size) {
int64_t est_size = est_bucket_num * sizeof(void *);
while (est_size > max_bound_size && est_bucket_num > 0) {
est_bucket_num >>= 1;
est_size = est_bucket_num * sizeof(void*);
}

View File

@ -1051,9 +1051,9 @@ int64_t ObHashPartInfrastructure<HashCol, HashRowStore>::est_bucket_count(
}
int64_t est_bucket_mem_size = next_pow2(rows) * sizeof(void*);
int64_t est_data_mem_size = rows * width;
int64_t max_remain_mem_size = sql_mem_processor_->get_mem_bound() - est_part_cnt_ * BLOCK_SIZE;
int64_t max_remain_mem_size = std::max(0l, sql_mem_processor_->get_mem_bound() - est_part_cnt_ * BLOCK_SIZE);
int64_t est_bucket_num = rows;
while (est_bucket_mem_size + est_data_mem_size > max_remain_mem_size) {
while (est_bucket_mem_size + est_data_mem_size > max_remain_mem_size && est_bucket_num > 0) {
est_bucket_num >>= 1;
est_bucket_mem_size = next_pow2(est_bucket_num) * sizeof(void*);
est_data_mem_size = est_bucket_num * width;
@ -1719,10 +1719,10 @@ template <typename Item>
int64_t ObHashPartitionExtendHashTable<Item>::estimate_bucket_num(
const int64_t bucket_num, const int64_t max_hash_mem, const int64_t min_bucket, const int64_t max_bucket)
{
int64_t max_bound_size = max_hash_mem * MAX_MEM_PERCENT / 100;
int64_t max_bound_size = std::max(0l, max_hash_mem * MAX_MEM_PERCENT / 100);
int64_t est_bucket_num = common::next_pow2(bucket_num);
int64_t est_size = est_bucket_num * sizeof(void*);
while (est_size > max_bound_size) {
int64_t est_size = est_bucket_num * sizeof(void *);
while (est_size > max_bound_size && est_bucket_num > 0) {
est_bucket_num >>= 1;
est_size = est_bucket_num * sizeof(void*);
}