[fix](reader) avoid be coredump in block reader in abnormal situation (#34878)
This commit is contained in:
@ -163,9 +163,9 @@ Status BlockReader::_init_collect_iter(const ReaderParams& read_params) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void BlockReader::_init_agg_state(const ReaderParams& read_params) {
|
||||
Status BlockReader::_init_agg_state(const ReaderParams& read_params) {
|
||||
if (_eof) {
|
||||
return;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
_stored_data_columns =
|
||||
@ -181,7 +181,14 @@ void BlockReader::_init_agg_state(const ReaderParams& read_params) {
|
||||
AggregateFunctionPtr function =
|
||||
column.get_aggregate_function(vectorized::AGG_READER_SUFFIX);
|
||||
|
||||
DCHECK(function != nullptr);
|
||||
// to avoid coredump when something goes wrong(i.e. column missmatch)
|
||||
if (!function) {
|
||||
return Status::InternalError(
|
||||
"Failed to init reader when init agg state: "
|
||||
"tablet_id: {}, schema_hash: {}, reader_type: {}, version: {}",
|
||||
read_params.tablet->tablet_id(), read_params.tablet->schema_hash(),
|
||||
int(read_params.reader_type), read_params.version.to_string());
|
||||
}
|
||||
_agg_functions.push_back(function);
|
||||
// create aggregate data
|
||||
AggregateDataPtr place = new char[function->size_of_data()];
|
||||
@ -194,6 +201,8 @@ void BlockReader::_init_agg_state(const ReaderParams& read_params) {
|
||||
// calculate `_has_variable_length_tag` tag. like string, array, map
|
||||
_stored_has_variable_length_tag[idx] = _stored_data_columns[idx]->is_variable_length();
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status BlockReader::init(const ReaderParams& read_params) {
|
||||
@ -246,7 +255,7 @@ Status BlockReader::init(const ReaderParams& read_params) {
|
||||
break;
|
||||
case KeysType::AGG_KEYS:
|
||||
_next_block_func = &BlockReader::_agg_key_next_block;
|
||||
_init_agg_state(read_params);
|
||||
RETURN_IF_ERROR(_init_agg_state(read_params));
|
||||
break;
|
||||
default:
|
||||
DCHECK(false) << "No next row function for type:" << tablet()->keys_type();
|
||||
|
||||
@ -72,7 +72,7 @@ private:
|
||||
|
||||
Status _init_collect_iter(const ReaderParams& read_params);
|
||||
|
||||
void _init_agg_state(const ReaderParams& read_params);
|
||||
Status _init_agg_state(const ReaderParams& read_params);
|
||||
|
||||
Status _insert_data_normal(MutableColumns& columns);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user