github-actions[bot] commented on code in PR #31317: URL: https://github.com/apache/doris/pull/31317#discussion_r1500271881
########## be/src/cloud/cloud_tablet.cpp: ########## @@ -443,4 +491,128 @@ _cumulative_point = new_point; } +Status CloudTablet::update_delete_bitmap(const std::shared_ptr<CloudTablet>& self, Review Comment: warning: function 'update_delete_bitmap' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp Status CloudTablet::update_delete_bitmap(const std::shared_ptr<CloudTablet>& self, ^ ``` <details> <summary>Additional context</summary> **be/src/cloud/cloud_tablet.cpp:493:** 117 lines including whitespace and comments (threshold 80) ```cpp Status CloudTablet::update_delete_bitmap(const std::shared_ptr<CloudTablet>& self, ^ ``` </details> ########## be/src/cloud/delete_bitmap_txn_manager.cpp: ########## @@ -0,0 +1,193 @@ +// 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/delete_bitmap_txn_manager.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 { + +// TODO sweep time +DeleteBitmapTxnManager::DeleteBitmapTxnManager(size_t size_in_bytes) + : LRUCachePolicy(CachePolicy::CacheType::CLOUD_DELETE_BITMAP_TXN_MANAGER, size_in_bytes, + LRUCacheType::SIZE, config::pk_index_page_cache_stale_sweep_time_sec, 4), + _stop_latch(1) {} + +DeleteBitmapTxnManager::~DeleteBitmapTxnManager() { + _stop_latch.count_down(); + _clean_thread->join(); +} + +Status DeleteBitmapTxnManager::init() { Review Comment: warning: method 'init' can be made static [readability-convert-member-functions-to-static] be/src/cloud/delete_bitmap_txn_manager.h:36: ```diff - Status init(); + static Status init(); ``` ########## be/src/cloud/cloud_tablet.cpp: ########## @@ -443,4 +491,128 @@ void CloudTablet::set_cumulative_layer_point(int64_t new_point) { _cumulative_point = new_point; } +Status CloudTablet::update_delete_bitmap(const std::shared_ptr<CloudTablet>& self, Review Comment: warning: method 'update_delete_bitmap' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status CloudTablet::update_delete_bitmap(const std::shared_ptr<CloudTablet>& self, ``` ########## be/src/olap/task/engine_calc_delete_bitmap_task.cpp: ########## @@ -0,0 +1,162 @@ +// 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 "olap/task/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/utils.h" + +namespace doris { + +EngineCalcDeleteBitmapTask::EngineCalcDeleteBitmapTask( + 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 EngineCalcDeleteBitmapTask::add_error_tablet_id(int64_t tablet_id, const Status& err) { Review Comment: warning: method 'add_error_tablet_id' can be made static [readability-convert-member-functions-to-static] be/src/olap/task/engine_calc_delete_bitmap_task.h:57: ```diff - void add_error_tablet_id(int64_t tablet_id, const Status& err); + static void add_error_tablet_id(int64_t tablet_id, const Status& err); ``` ########## be/src/cloud/delete_bitmap_txn_manager.cpp: ########## @@ -0,0 +1,193 @@ +// 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/delete_bitmap_txn_manager.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 { + +// TODO sweep time +DeleteBitmapTxnManager::DeleteBitmapTxnManager(size_t size_in_bytes) + : LRUCachePolicy(CachePolicy::CacheType::CLOUD_DELETE_BITMAP_TXN_MANAGER, size_in_bytes, + LRUCacheType::SIZE, config::pk_index_page_cache_stale_sweep_time_sec, 4), + _stop_latch(1) {} + +DeleteBitmapTxnManager::~DeleteBitmapTxnManager() { Review Comment: warning: use '= default' to define a trivial destructor [modernize-use-equals-default] ```cpp DeleteBitmapTxnManager::~DeleteBitmapTxnManager() { ^ ``` ########## be/src/cloud/delete_bitmap_txn_manager.h: ########## @@ -0,0 +1,94 @@ +// 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. + +#pragma once + +#include <mutex> + +#include "olap/lru_cache.h" +#include "olap/olap_common.h" +#include "olap/partial_update_info.h" +#include "olap/rowset/rowset.h" +#include "olap/tablet_meta.h" +#include "util/countdown_latch.h" + +namespace doris { + +class DeleteBitmapTxnManager : public LRUCachePolicy { +public: + DeleteBitmapTxnManager(size_t size_in_bytes); + + ~DeleteBitmapTxnManager(); Review Comment: warning: annotate this function with 'override' or (rarely) 'final' [modernize-use-override] ```suggestion ~DeleteBitmapTxnManager() override; ``` ########## be/src/cloud/cloud_rowset_builder.cpp: ########## @@ -104,4 +107,24 @@ const RowsetMetaSharedPtr& CloudRowsetBuilder::rowset_meta() { return _rowset_writer->rowset_meta(); } +Status CloudRowsetBuilder::set_txn_related_delete_bitmap() { Review Comment: warning: method 'set_txn_related_delete_bitmap' can be made static [readability-convert-member-functions-to-static] be/src/cloud/cloud_rowset_builder.h:39: ```diff - Status set_txn_related_delete_bitmap(); + static Status set_txn_related_delete_bitmap(); ``` ########## be/src/olap/rowset_builder.cpp: ########## @@ -119,7 +119,7 @@ void RowsetBuilder::_garbage_collection() { } } -Status RowsetBuilder::init_mow_context(std::shared_ptr<MowContext>& mow_context) { +Status BaseRowsetBuilder::init_mow_context(std::shared_ptr<MowContext>& mow_context) { Review Comment: warning: method 'init_mow_context' can be made static [readability-convert-member-functions-to-static] be/src/olap/rowset_builder.h:84: ```diff - Status init_mow_context(std::shared_ptr<MowContext>& mow_context); + static Status init_mow_context(std::shared_ptr<MowContext>& mow_context); ``` ########## be/src/olap/base_tablet.cpp: ########## @@ -1059,4 +1060,82 @@ Status BaseTablet::_capture_consistent_rowsets_unlocked( return Status::OK(); } +Status BaseTablet::check_delete_bitmap_correctness(DeleteBitmapPtr delete_bitmap, Review Comment: warning: method 'check_delete_bitmap_correctness' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status BaseTablet::check_delete_bitmap_correctness(DeleteBitmapPtr delete_bitmap, ``` ########## be/src/olap/task/engine_calc_delete_bitmap_task.cpp: ########## @@ -0,0 +1,162 @@ +// 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 "olap/task/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/utils.h" + +namespace doris { + +EngineCalcDeleteBitmapTask::EngineCalcDeleteBitmapTask( + 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 EngineCalcDeleteBitmapTask::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 EngineCalcDeleteBitmapTask::add_succ_tablet_id(int64_t tablet_id) { + std::lock_guard<std::mutex> lck(_mutex); + _succ_tablet_ids->push_back(tablet_id); +} + +Status EngineCalcDeleteBitmapTask::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<TabletCalcDeleteBitmapTask>( + _engine, this, tablet, transaction_id, version); + auto submit_st = token->submit_func([=]() { tablet_calc_delete_bitmap_ptr->handle(); }); + CHECK(submit_st.ok()); + } + } + // wait for all finished + token->wait(); + + LOG(INFO) << "finish to calculate delete bitmap on transaction." + << "transaction_id=" << transaction_id << ", cost(us): " << watch.get_elapse_time_us() + << ", error_tablet_size=" << _error_tablet_ids->size() + << ", res=" << _res.to_string(); + return _res; +} + +TabletCalcDeleteBitmapTask::TabletCalcDeleteBitmapTask(CloudStorageEngine& engine, + EngineCalcDeleteBitmapTask* engine_task, + std::shared_ptr<CloudTablet> tablet, + int64_t transaction_id, int64_t version) + : _engine(engine), + _engine_calc_delete_bitmap_task(engine_task), + _tablet(tablet), + _transaction_id(transaction_id), + _version(version) {} + +void TabletCalcDeleteBitmapTask::handle() { Review Comment: warning: method 'handle' can be made const [readability-make-member-function-const] ```suggestion void TabletCalcDeleteBitmapTask::handle() const { ``` be/src/olap/task/engine_calc_delete_bitmap_task.h:38: ```diff - void handle(); + void handle() const; ``` ########## be/src/olap/task/engine_calc_delete_bitmap_task.cpp: ########## @@ -0,0 +1,162 @@ +// 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 "olap/task/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/utils.h" + +namespace doris { + +EngineCalcDeleteBitmapTask::EngineCalcDeleteBitmapTask( + 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 EngineCalcDeleteBitmapTask::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 EngineCalcDeleteBitmapTask::add_succ_tablet_id(int64_t tablet_id) { Review Comment: warning: method 'add_succ_tablet_id' can be made static [readability-convert-member-functions-to-static] be/src/olap/task/engine_calc_delete_bitmap_task.h:58: ```diff - void add_succ_tablet_id(int64_t tablet_id); + static void add_succ_tablet_id(int64_t tablet_id); ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org