zhannngchen commented on code in PR #31317: URL: https://github.com/apache/doris/pull/31317#discussion_r1507668133
########## be/src/cloud/cloud_engine_calc_delete_bitmap_task.cpp: ########## @@ -0,0 +1,165 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "cloud/cloud_engine_calc_delete_bitmap_task.h" + +#include <memory> + +#include "cloud/cloud_meta_mgr.h" +#include "cloud/cloud_tablet.h" +#include "common/status.h" +#include "olap/base_tablet.h" +#include "olap/olap_common.h" +#include "olap/rowset/rowset.h" +#include "olap/tablet_fwd.h" +#include "olap/tablet_meta.h" +#include "olap/txn_manager.h" +#include "olap/utils.h" + +namespace doris { + +CloudEngineCalcDeleteBitmapTask::CloudEngineCalcDeleteBitmapTask( + CloudStorageEngine& engine, const TCalcDeleteBitmapRequest& cal_delete_bitmap_req, + std::vector<TTabletId>* error_tablet_ids, std::vector<TTabletId>* succ_tablet_ids) + : _engine(engine), + _cal_delete_bitmap_req(cal_delete_bitmap_req), + _error_tablet_ids(error_tablet_ids), + _succ_tablet_ids(succ_tablet_ids) {} + +void CloudEngineCalcDeleteBitmapTask::add_error_tablet_id(int64_t tablet_id, const Status& err) { + std::lock_guard<std::mutex> lck(_mutex); + _error_tablet_ids->push_back(tablet_id); + if (_res.ok() || _res.is<ErrorCode::DELETE_BITMAP_LOCK_ERROR>()) { + _res = err; + } +} + +void CloudEngineCalcDeleteBitmapTask::add_succ_tablet_id(int64_t tablet_id) { + std::lock_guard<std::mutex> lck(_mutex); + _succ_tablet_ids->push_back(tablet_id); +} + +Status CloudEngineCalcDeleteBitmapTask::execute() { + int64_t transaction_id = _cal_delete_bitmap_req.transaction_id; + OlapStopWatch watch; + VLOG_NOTICE << "begin to calculate delete bitmap. transaction_id=" << transaction_id; + std::unique_ptr<ThreadPoolToken> token = + _engine.calc_tablet_delete_bitmap_task_thread_pool()->new_token( + ThreadPool::ExecutionMode::CONCURRENT); + + for (const auto& partition : _cal_delete_bitmap_req.partitions) { + int64_t version = partition.version; + for (auto tablet_id : partition.tablet_ids) { + auto base_tablet = DORIS_TRY(_engine.get_tablet(tablet_id)); + std::shared_ptr<CloudTablet> tablet = + std::dynamic_pointer_cast<CloudTablet>(base_tablet); + if (tablet == nullptr) { + LOG(WARNING) << "can't get tablet when calculate delete bitmap. tablet_id=" + << tablet_id; + _error_tablet_ids->push_back(tablet_id); + _res = Status::Error<ErrorCode::PUSH_TABLE_NOT_EXIST>( + "can't get tablet when calculate delete bitmap. tablet_id={}", tablet_id); + break; + } + + Status st = tablet->sync_rowsets(); + if (!st.ok() && !st.is<ErrorCode::INVALID_TABLET_STATE>()) { + return st; + } + if (st.is<ErrorCode::INVALID_TABLET_STATE>()) [[unlikely]] { + add_succ_tablet_id(tablet->tablet_id()); + LOG(INFO) + << "tablet is under alter process, delete bitmap will be calculated later, " + "tablet_id: " + << tablet->tablet_id() << " txn_id: " << transaction_id + << ", request_version=" << version; + continue; + } + int64_t max_version = tablet->max_version_unlocked(); + if (version != max_version + 1) { + _error_tablet_ids->push_back(tablet_id); + _res = Status::Error<ErrorCode::DELETE_BITMAP_LOCK_ERROR, false>( + "version not continuous"); + LOG(WARNING) << "version not continuous, current max version=" << max_version + << ", request_version=" << version + << " tablet_id=" << tablet->tablet_id(); + break; + } + + auto tablet_calc_delete_bitmap_ptr = std::make_shared<CloudTabletCalcDeleteBitmapTask>( + _engine, this, tablet, transaction_id, version); + auto submit_st = token->submit_func([=]() { tablet_calc_delete_bitmap_ptr->handle(); }); + CHECK(submit_st.ok()); Review Comment: if we can handle the error, we should not use CHECK ########## be/src/cloud/cloud_engine_calc_delete_bitmap_task.cpp: ########## @@ -0,0 +1,165 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "cloud/cloud_engine_calc_delete_bitmap_task.h" + +#include <memory> + +#include "cloud/cloud_meta_mgr.h" +#include "cloud/cloud_tablet.h" +#include "common/status.h" +#include "olap/base_tablet.h" +#include "olap/olap_common.h" +#include "olap/rowset/rowset.h" +#include "olap/tablet_fwd.h" +#include "olap/tablet_meta.h" +#include "olap/txn_manager.h" +#include "olap/utils.h" + +namespace doris { + +CloudEngineCalcDeleteBitmapTask::CloudEngineCalcDeleteBitmapTask( + CloudStorageEngine& engine, const TCalcDeleteBitmapRequest& cal_delete_bitmap_req, + std::vector<TTabletId>* error_tablet_ids, std::vector<TTabletId>* succ_tablet_ids) + : _engine(engine), + _cal_delete_bitmap_req(cal_delete_bitmap_req), + _error_tablet_ids(error_tablet_ids), + _succ_tablet_ids(succ_tablet_ids) {} + +void CloudEngineCalcDeleteBitmapTask::add_error_tablet_id(int64_t tablet_id, const Status& err) { + std::lock_guard<std::mutex> lck(_mutex); + _error_tablet_ids->push_back(tablet_id); + if (_res.ok() || _res.is<ErrorCode::DELETE_BITMAP_LOCK_ERROR>()) { + _res = err; + } +} + +void CloudEngineCalcDeleteBitmapTask::add_succ_tablet_id(int64_t tablet_id) { + std::lock_guard<std::mutex> lck(_mutex); + _succ_tablet_ids->push_back(tablet_id); +} + +Status CloudEngineCalcDeleteBitmapTask::execute() { + int64_t transaction_id = _cal_delete_bitmap_req.transaction_id; + OlapStopWatch watch; + VLOG_NOTICE << "begin to calculate delete bitmap. transaction_id=" << transaction_id; + std::unique_ptr<ThreadPoolToken> token = + _engine.calc_tablet_delete_bitmap_task_thread_pool()->new_token( + ThreadPool::ExecutionMode::CONCURRENT); + + for (const auto& partition : _cal_delete_bitmap_req.partitions) { + int64_t version = partition.version; + for (auto tablet_id : partition.tablet_ids) { + auto base_tablet = DORIS_TRY(_engine.get_tablet(tablet_id)); + std::shared_ptr<CloudTablet> tablet = + std::dynamic_pointer_cast<CloudTablet>(base_tablet); + if (tablet == nullptr) { + LOG(WARNING) << "can't get tablet when calculate delete bitmap. tablet_id=" + << tablet_id; + _error_tablet_ids->push_back(tablet_id); + _res = Status::Error<ErrorCode::PUSH_TABLE_NOT_EXIST>( + "can't get tablet when calculate delete bitmap. tablet_id={}", tablet_id); + break; + } + + Status st = tablet->sync_rowsets(); + if (!st.ok() && !st.is<ErrorCode::INVALID_TABLET_STATE>()) { + return st; + } + if (st.is<ErrorCode::INVALID_TABLET_STATE>()) [[unlikely]] { + add_succ_tablet_id(tablet->tablet_id()); + LOG(INFO) + << "tablet is under alter process, delete bitmap will be calculated later, " Review Comment: No extra processing needed for schema change on cloud? I don't see any relevant changes ########## be/src/cloud/cloud_txn_delete_bitmap_cache.cpp: ########## @@ -0,0 +1,192 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "cloud/cloud_txn_delete_bitmap_cache.h" + +#include <fmt/core.h> + +#include <chrono> +#include <memory> +#include <shared_mutex> + +#include "common/status.h" +#include "common/sync_point.h" +#include "olap/olap_common.h" +#include "olap/tablet_meta.h" + +namespace doris { + +CloudTxnDeleteBitmapCache::CloudTxnDeleteBitmapCache(size_t size_in_bytes) + : LRUCachePolicy(CachePolicy::CacheType::CLOUD_TXN_DELETE_BITMAP_CACHE, size_in_bytes, + LRUCacheType::SIZE, 86400, 4), + _stop_latch(1) {} + +CloudTxnDeleteBitmapCache::~CloudTxnDeleteBitmapCache() { + _stop_latch.count_down(); + _clean_thread->join(); +} + +Status CloudTxnDeleteBitmapCache::init() { + auto st = Thread::create( + "CloudTxnDeleteBitmapCache", "clean_txn_dbm_thread", + [this]() { this->_clean_thread_callback(); }, &_clean_thread); + if (!st.ok()) { + LOG(WARNING) << "failed to create thread for CloudTxnDeleteBitmapCache, error: " << st; + } + return st; +} + +Status CloudTxnDeleteBitmapCache::get_tablet_txn_info( + TTransactionId transaction_id, int64_t tablet_id, RowsetSharedPtr* rowset, + DeleteBitmapPtr* delete_bitmap, RowsetIdUnorderedSet* rowset_ids, int64_t* txn_expiration, + std::shared_ptr<PartialUpdateInfo>* partial_update_info) { + { + std::shared_lock<std::shared_mutex> rlock(_rwlock); + TxnKey key(transaction_id, tablet_id); + auto iter = _txn_map.find(key); + if (iter == _txn_map.end()) { + return Status::Error<ErrorCode::NOT_FOUND, false>( + "not found txn info, tablet_id={}, transaction_id={}", tablet_id, + transaction_id); + } + *rowset = iter->second.rowset; + *txn_expiration = iter->second.txn_expiration; + *partial_update_info = iter->second.partial_update_info; + } + std::string key_str = fmt::format("{}/{}", transaction_id, tablet_id); + CacheKey key(key_str); + Cache::Handle* handle = cache()->lookup(key); + + DeleteBitmapCacheValue* val = + handle == nullptr ? nullptr + : reinterpret_cast<DeleteBitmapCacheValue*>(cache()->value(handle)); + if (val) { + *delete_bitmap = val->delete_bitmap; + *rowset_ids = val->rowset_ids; + // must call release handle to reduce the reference count, + // otherwise there will be memory leak + cache()->release(handle); + } else { + LOG_INFO("cache missed when get delete bitmap") + .tag("txn_id", transaction_id) + .tag("tablt_id", tablet_id); Review Comment: typo:tablet_id ########## be/src/cloud/cloud_txn_delete_bitmap_cache.cpp: ########## @@ -0,0 +1,192 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "cloud/cloud_txn_delete_bitmap_cache.h" + +#include <fmt/core.h> + +#include <chrono> +#include <memory> +#include <shared_mutex> + +#include "common/status.h" +#include "common/sync_point.h" +#include "olap/olap_common.h" +#include "olap/tablet_meta.h" + +namespace doris { + +CloudTxnDeleteBitmapCache::CloudTxnDeleteBitmapCache(size_t size_in_bytes) + : LRUCachePolicy(CachePolicy::CacheType::CLOUD_TXN_DELETE_BITMAP_CACHE, size_in_bytes, + LRUCacheType::SIZE, 86400, 4), + _stop_latch(1) {} + +CloudTxnDeleteBitmapCache::~CloudTxnDeleteBitmapCache() { + _stop_latch.count_down(); + _clean_thread->join(); +} + +Status CloudTxnDeleteBitmapCache::init() { + auto st = Thread::create( + "CloudTxnDeleteBitmapCache", "clean_txn_dbm_thread", + [this]() { this->_clean_thread_callback(); }, &_clean_thread); + if (!st.ok()) { + LOG(WARNING) << "failed to create thread for CloudTxnDeleteBitmapCache, error: " << st; + } + return st; +} + +Status CloudTxnDeleteBitmapCache::get_tablet_txn_info( + TTransactionId transaction_id, int64_t tablet_id, RowsetSharedPtr* rowset, + DeleteBitmapPtr* delete_bitmap, RowsetIdUnorderedSet* rowset_ids, int64_t* txn_expiration, + std::shared_ptr<PartialUpdateInfo>* partial_update_info) { + { + std::shared_lock<std::shared_mutex> rlock(_rwlock); + TxnKey key(transaction_id, tablet_id); + auto iter = _txn_map.find(key); + if (iter == _txn_map.end()) { + return Status::Error<ErrorCode::NOT_FOUND, false>( + "not found txn info, tablet_id={}, transaction_id={}", tablet_id, + transaction_id); + } + *rowset = iter->second.rowset; + *txn_expiration = iter->second.txn_expiration; + *partial_update_info = iter->second.partial_update_info; + } + std::string key_str = fmt::format("{}/{}", transaction_id, tablet_id); + CacheKey key(key_str); + Cache::Handle* handle = cache()->lookup(key); + + DeleteBitmapCacheValue* val = + handle == nullptr ? nullptr + : reinterpret_cast<DeleteBitmapCacheValue*>(cache()->value(handle)); + if (val) { + *delete_bitmap = val->delete_bitmap; + *rowset_ids = val->rowset_ids; + // must call release handle to reduce the reference count, + // otherwise there will be memory leak + cache()->release(handle); + } else { + LOG_INFO("cache missed when get delete bitmap") + .tag("txn_id", transaction_id) + .tag("tablt_id", tablet_id); + // Becasue of the rowset_ids become empty, all delete bitmap + // will be recalculate in CalcDeleteBitmapTask + *delete_bitmap = std::make_shared<DeleteBitmap>(tablet_id); + } + return Status::OK(); +} + +void CloudTxnDeleteBitmapCache::set_tablet_txn_info( + TTransactionId transaction_id, int64_t tablet_id, DeleteBitmapPtr delete_bitmap, + const RowsetIdUnorderedSet& rowset_ids, RowsetSharedPtr rowset, int64_t txn_expiration, + std::shared_ptr<PartialUpdateInfo> partial_update_info) { + if (txn_expiration <= 0) { + txn_expiration = duration_cast<std::chrono::seconds>( + std::chrono::system_clock::now().time_since_epoch()) + .count() + + 120; + } + { + std::unique_lock<std::shared_mutex> wlock(_rwlock); + TxnKey txn_key(transaction_id, tablet_id); + _txn_map[txn_key] = TxnVal(rowset, txn_expiration, std::move(partial_update_info)); + _expiration_txn.emplace(txn_expiration, txn_key); + } + std::string key_str = fmt::format("{}/{}", transaction_id, tablet_id); + CacheKey key(key_str); + + auto val = new DeleteBitmapCacheValue(delete_bitmap, rowset_ids); + auto deleter = [](const CacheKey&, void* value) { + delete (DeleteBitmapCacheValue*)value; // Just delete to reclaim + }; + size_t charge = sizeof(DeleteBitmapCacheValue); + for (auto& [k, v] : val->delete_bitmap->delete_bitmap) { + charge += v.getSizeInBytes(); + } + auto handle = cache()->insert(key, val, charge, deleter, CachePriority::NORMAL); + // must call release handle to reduce the reference count, + // otherwise there will be memory leak + cache()->release(handle); + LOG_INFO("set txn related delete bitmap") + .tag("txn_id", transaction_id) + .tag("expiration", txn_expiration) + .tag("tablt_id", tablet_id) + .tag("delete_bitmap_size", charge); +} + +void CloudTxnDeleteBitmapCache::update_tablet_txn_info(TTransactionId transaction_id, + int64_t tablet_id, + DeleteBitmapPtr delete_bitmap, + const RowsetIdUnorderedSet& rowset_ids) { + std::string key_str = fmt::format("{}/{}", transaction_id, tablet_id); + CacheKey key(key_str); + + DeleteBitmapPtr new_delete_bitmap = std::make_shared<DeleteBitmap>(tablet_id); + *new_delete_bitmap = *delete_bitmap; Review Comment: why do we need to copy value here? ########## be/src/cloud/cloud_tablets_channel.cpp: ########## @@ -235,7 +235,16 @@ Status CloudTabletsChannel::close(LoadChannel* parent, const PTabletWriterAddBlo } } - // TODO(plat1ko): 6. set txn related delete bitmap if necessary + // 6. set txn related delete bitmap if necessary Review Comment: do we need to sync rowset before L216(auto st = writer->submit_calc_delete_bitmap_task();)? ########## be/src/cloud/cloud_tablet.cpp: ########## @@ -443,4 +479,52 @@ void CloudTablet::set_cumulative_layer_point(int64_t new_point) { _cumulative_point = new_point; } +CalcDeleteBitmapExecutor* CloudTablet::calc_delete_bitmap_executor() { + return _engine.calc_delete_bitmap_executor(); +} + +Status CloudTablet::save_delete_bitmap(const TabletTxnInfo* txn_info, int64_t txn_id, + DeleteBitmapPtr delete_bitmap, RowsetWriter* rowset_writer, + const RowsetIdUnorderedSet& cur_rowset_ids) { + RowsetSharedPtr rowset = txn_info->rowset; + int64_t cur_version = rowset->start_version(); + // update delete bitmap info, in order to avoid recalculation when trying again + _engine.txn_delete_bitmap_cache().update_tablet_txn_info(txn_id, tablet_id(), delete_bitmap, + cur_rowset_ids); + + if (txn_info->partial_update_info && txn_info->partial_update_info->is_partial_update && + rowset_writer->num_rows() > 0) { + DBUG_EXECUTE_IF("CloudTablet.update_delete_bitmap.partial_update_write_rowset_fail", { Review Comment: the debug point name changed, we should update the regression-test for cloud as well? ########## be/src/cloud/cloud_txn_delete_bitmap_cache.cpp: ########## @@ -0,0 +1,192 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "cloud/cloud_txn_delete_bitmap_cache.h" + +#include <fmt/core.h> + +#include <chrono> +#include <memory> +#include <shared_mutex> + +#include "common/status.h" +#include "common/sync_point.h" +#include "olap/olap_common.h" +#include "olap/tablet_meta.h" + +namespace doris { + +CloudTxnDeleteBitmapCache::CloudTxnDeleteBitmapCache(size_t size_in_bytes) + : LRUCachePolicy(CachePolicy::CacheType::CLOUD_TXN_DELETE_BITMAP_CACHE, size_in_bytes, + LRUCacheType::SIZE, 86400, 4), + _stop_latch(1) {} + +CloudTxnDeleteBitmapCache::~CloudTxnDeleteBitmapCache() { + _stop_latch.count_down(); + _clean_thread->join(); +} + +Status CloudTxnDeleteBitmapCache::init() { + auto st = Thread::create( + "CloudTxnDeleteBitmapCache", "clean_txn_dbm_thread", + [this]() { this->_clean_thread_callback(); }, &_clean_thread); + if (!st.ok()) { + LOG(WARNING) << "failed to create thread for CloudTxnDeleteBitmapCache, error: " << st; + } + return st; +} + +Status CloudTxnDeleteBitmapCache::get_tablet_txn_info( + TTransactionId transaction_id, int64_t tablet_id, RowsetSharedPtr* rowset, + DeleteBitmapPtr* delete_bitmap, RowsetIdUnorderedSet* rowset_ids, int64_t* txn_expiration, + std::shared_ptr<PartialUpdateInfo>* partial_update_info) { + { + std::shared_lock<std::shared_mutex> rlock(_rwlock); + TxnKey key(transaction_id, tablet_id); + auto iter = _txn_map.find(key); + if (iter == _txn_map.end()) { + return Status::Error<ErrorCode::NOT_FOUND, false>( + "not found txn info, tablet_id={}, transaction_id={}", tablet_id, + transaction_id); + } + *rowset = iter->second.rowset; + *txn_expiration = iter->second.txn_expiration; + *partial_update_info = iter->second.partial_update_info; + } + std::string key_str = fmt::format("{}/{}", transaction_id, tablet_id); + CacheKey key(key_str); + Cache::Handle* handle = cache()->lookup(key); + + DeleteBitmapCacheValue* val = + handle == nullptr ? nullptr + : reinterpret_cast<DeleteBitmapCacheValue*>(cache()->value(handle)); + if (val) { + *delete_bitmap = val->delete_bitmap; + *rowset_ids = val->rowset_ids; + // must call release handle to reduce the reference count, + // otherwise there will be memory leak + cache()->release(handle); + } else { + LOG_INFO("cache missed when get delete bitmap") + .tag("txn_id", transaction_id) + .tag("tablt_id", tablet_id); + // Becasue of the rowset_ids become empty, all delete bitmap + // will be recalculate in CalcDeleteBitmapTask + *delete_bitmap = std::make_shared<DeleteBitmap>(tablet_id); + } + return Status::OK(); +} + +void CloudTxnDeleteBitmapCache::set_tablet_txn_info( + TTransactionId transaction_id, int64_t tablet_id, DeleteBitmapPtr delete_bitmap, + const RowsetIdUnorderedSet& rowset_ids, RowsetSharedPtr rowset, int64_t txn_expiration, + std::shared_ptr<PartialUpdateInfo> partial_update_info) { + if (txn_expiration <= 0) { + txn_expiration = duration_cast<std::chrono::seconds>( + std::chrono::system_clock::now().time_since_epoch()) + .count() + + 120; + } + { + std::unique_lock<std::shared_mutex> wlock(_rwlock); + TxnKey txn_key(transaction_id, tablet_id); + _txn_map[txn_key] = TxnVal(rowset, txn_expiration, std::move(partial_update_info)); + _expiration_txn.emplace(txn_expiration, txn_key); + } + std::string key_str = fmt::format("{}/{}", transaction_id, tablet_id); + CacheKey key(key_str); + + auto val = new DeleteBitmapCacheValue(delete_bitmap, rowset_ids); + auto deleter = [](const CacheKey&, void* value) { + delete (DeleteBitmapCacheValue*)value; // Just delete to reclaim + }; + size_t charge = sizeof(DeleteBitmapCacheValue); + for (auto& [k, v] : val->delete_bitmap->delete_bitmap) { + charge += v.getSizeInBytes(); + } + auto handle = cache()->insert(key, val, charge, deleter, CachePriority::NORMAL); + // must call release handle to reduce the reference count, + // otherwise there will be memory leak + cache()->release(handle); + LOG_INFO("set txn related delete bitmap") + .tag("txn_id", transaction_id) + .tag("expiration", txn_expiration) + .tag("tablt_id", tablet_id) Review Comment: ditto -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
