From e5cff86fa96ef3448297c76a19493f2b57dff8bd Mon Sep 17 00:00:00 2001 From: saltonz Date: Fri, 3 Nov 2023 11:16:54 +0000 Subject: [PATCH] [bugfix] deep copy encrypt key to io callback --- .../blocksstable/ob_micro_block_cache.cpp | 27 ++++++++++--------- .../blocksstable/ob_micro_block_cache.h | 4 ++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/storage/blocksstable/ob_micro_block_cache.cpp b/src/storage/blocksstable/ob_micro_block_cache.cpp index b76fe20127..a4a10e7b08 100644 --- a/src/storage/blocksstable/ob_micro_block_cache.cpp +++ b/src/storage/blocksstable/ob_micro_block_cache.cpp @@ -278,7 +278,7 @@ void ObMultiBlockIOParam::get_io_range(int64_t &offset, int64_t &size) const } } -int ObMultiBlockIOParam::get_block_des_info(ObMicroBlockDesMeta &des_meta) const +int ObMultiBlockIOParam::get_block_des_info(ObIMicroBlockIOCallback &io_callback) const { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_valid())) { @@ -286,11 +286,7 @@ int ObMultiBlockIOParam::get_block_des_info(ObMicroBlockDesMeta &des_meta) const LOG_WARN("Invalid multi block io parameter", K(ret), K(*this)); } else { ObMicroIndexInfo &start_info = micro_index_infos_->at(start_index_); - des_meta.compressor_type_ = start_info.row_header_->get_compressor_type(); - des_meta.encrypt_id_ = start_info.row_header_->get_encrypt_id(); - des_meta.master_key_id_ = start_info.row_header_->get_master_key_id(); - des_meta.encrypt_key_ = start_info.row_header_->get_encrypt_key(); - des_meta.row_store_type_ = start_info.row_header_->get_row_store_type(); + io_callback.set_micro_des_meta(start_info.row_header_); } return ret; } @@ -319,6 +315,7 @@ ObIMicroBlockIOCallback::ObIMicroBlockIOCallback() use_block_cache_(true) { MEMSET(encrypt_key_, 0, sizeof(encrypt_key_)); + block_des_meta_.encrypt_key_ = encrypt_key_; static_assert(sizeof(*this) <= CALLBACK_BUF_SIZE, "IOCallback buf size not enough"); } @@ -331,6 +328,16 @@ ObIMicroBlockIOCallback::~ObIMicroBlockIOCallback() allocator_ = nullptr; } +void ObIMicroBlockIOCallback::set_micro_des_meta(const ObIndexBlockRowHeader *idx_row_header) +{ + OB_ASSERT(nullptr != idx_row_header); + block_des_meta_.compressor_type_ = idx_row_header->get_compressor_type(); + block_des_meta_.encrypt_id_ = idx_row_header->get_encrypt_id(); + block_des_meta_.master_key_id_ = idx_row_header->get_master_key_id(); + block_des_meta_.row_store_type_ = idx_row_header->get_row_store_type(); + MEMCPY(encrypt_key_, idx_row_header->get_encrypt_key(), share::OB_MAX_TABLESPACE_ENCRYPT_KEY_LENGTH); +} + int ObIMicroBlockIOCallback::alloc_data_buf(const char *io_data_buffer, const int64_t data_size) { //UNUSED NOW @@ -815,11 +822,7 @@ int ObIMicroBlockCache::prefetch( callback.tenant_id_ = tenant_id; callback.block_id_ = macro_id; callback.offset_ = idx_row.get_block_offset(); - callback.block_des_meta_.compressor_type_ = idx_row_header->get_compressor_type(); - callback.block_des_meta_.encrypt_id_ = idx_row_header->get_encrypt_id(); - callback.block_des_meta_.master_key_id_ = idx_row_header->get_master_key_id(); - callback.block_des_meta_.encrypt_key_ = idx_row_header->get_encrypt_key(); - callback.block_des_meta_.row_store_type_ = idx_row.get_row_store_type(); + callback.set_micro_des_meta(idx_row_header); // fill read info ObMacroBlockReadInfo read_info; read_info.macro_block_id_ = macro_id; @@ -850,7 +853,7 @@ int ObIMicroBlockCache::prefetch( int ret = OB_SUCCESS; int64_t offset = 0; int64_t size = 0; - if (OB_FAIL(io_param.get_block_des_info(callback.block_des_meta_))) { + if (OB_FAIL(io_param.get_block_des_info(callback))) { LOG_WARN("Fail to get meta data for deserializing block data", K(ret), K(io_param)); } else { // fill callback diff --git a/src/storage/blocksstable/ob_micro_block_cache.h b/src/storage/blocksstable/ob_micro_block_cache.h index 2b29276ab6..dff9db05c4 100644 --- a/src/storage/blocksstable/ob_micro_block_cache.h +++ b/src/storage/blocksstable/ob_micro_block_cache.h @@ -28,6 +28,7 @@ namespace oceanbase { namespace blocksstable { +class ObIMicroBlockIOCallback; class ObMicroBlockCacheKey : public common::ObIKVCacheKey { public: @@ -122,7 +123,7 @@ struct ObMultiBlockIOParam void reset(); bool is_valid() const; inline void get_io_range(int64_t &offset, int64_t &size) const; - inline int get_block_des_info(ObMicroBlockDesMeta &des_meta) const; + inline int get_block_des_info(ObIMicroBlockIOCallback &des_meta) const; TO_STRING_KV(KPC(micro_index_infos_), K_(start_index), K_(block_count)); common::ObIArray *micro_index_infos_; int64_t start_index_; @@ -158,6 +159,7 @@ public: virtual ~ObIMicroBlockIOCallback(); virtual int alloc_data_buf(const char *io_data_buffer, const int64_t data_size); virtual ObIAllocator *get_allocator() { return allocator_; } + void set_micro_des_meta(const ObIndexBlockRowHeader *idx_row_header); protected: friend class ObIMicroBlockCache; friend class ObDataMicroBlockCache;