liaoxin01 commented on code in PR #31317:
URL: https://github.com/apache/doris/pull/31317#discussion_r1508822030


##########
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:
   schema change and compaction will be submitted in next pr.



-- 
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]

Reply via email to