From 07a56f46363b23a1e6210d3b3c517ec1c5e66b9a Mon Sep 17 00:00:00 2001 From: yangqise7en <877793735@qq.com> Date: Thu, 29 Jun 2023 12:42:20 +0000 Subject: [PATCH] fix request_cnt in decoder cause col ckm error --- .../encoding/ob_micro_block_decoder.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp b/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp index 39b0e588b7..17924816e5 100644 --- a/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp +++ b/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp @@ -1153,12 +1153,21 @@ int ObMicroBlockDecoder::init_decoders() if (OB_ISNULL(read_info_) || typeid(ObRowkeyReadInfo) == typeid(*read_info_)) { ObObjMeta col_type; const int64_t col_cnt = MIN(request_cnt_, header_->column_count_); - for (int64_t i = 0; OB_SUCC(ret) && i < col_cnt; ++i) { + int64_t i = 0; + for ( ; OB_SUCC(ret) && i < col_cnt; ++i) { col_type.set_type(static_cast(col_header_[i].obj_type_)); if (OB_FAIL(add_decoder(i, col_type, decoders_[i]))) { LOG_WARN("add_decoder failed", K(ret), K(i), K(col_type)); } } + if (OB_SUCC(ret) && i < request_cnt_ && OB_ISNULL(read_info_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("for empty read info, request cnt is invalid", KR(ret), KP(read_info_), KPC(header_), K(request_cnt_)); + } + for ( ; OB_SUCC(ret) && i < request_cnt_; ++i) { // add nop decoder for not-exist col + decoders_[i].decoder_ = &none_exist_column_decoder_; + decoders_[i].ctx_ = &none_exist_column_decoder_ctx_; + } } else { const ObColumnIndexArray &cols_index = read_info_->get_columns_index(); const ObColDescIArray &cols_desc = read_info_->get_columns_desc(); @@ -1442,7 +1451,7 @@ OB_INLINE int ObMicroBlockDecoder::get_row_impl(int64_t index, ObDatumRow &row) } else if (row.get_capacity() < request_cnt_) { ret = OB_BUF_NOT_ENOUGH; LOG_WARN("obj buf is not enough", K(ret), "expect_obj_count", request_cnt_, K(row)); - } else if (OB_FAIL(decode_cells(index, row_len, row_data, 0, MIN(request_cnt_, header_->column_count_), row.storage_datums_))) { + } else if (OB_FAIL(decode_cells(index, row_len, row_data, 0, request_cnt_, row.storage_datums_))) { LOG_WARN("decode cells failed", K(ret), K(index), K_(request_cnt)); } else { row.row_flag_.reset();