gavinchou commented on code in PR #66598:
URL: https://github.com/apache/doris/pull/66598#discussion_r3818248773


##########
cloud/src/meta-service/meta_service.cpp:
##########
@@ -3803,6 +3803,78 @@ struct UpdateDeleteBitmapTxnStats {
     size_t total_txn_count = 0;
 };
 
+static bool check_delete_bitmap_point_delete(MetaServiceCode& code, 
std::string& msg,
+                                             std::unique_ptr<Transaction>& txn,
+                                             const std::string& key, const 
std::string& val,
+                                             const UpdateDeleteBitmapRequest* 
request,
+                                             bool& point_delete, bool& 
delete_bitmap_exists,
+                                             std::optional<size_t>& 
max_blob_sequence) {
+    point_delete = config::enable_remove_pre_rowsets_delete_bitmap_by_keys &&
+                   request->lock_id() == 
COMPACTION_WITHOUT_LOCK_DELETE_BITMAP_LOCK_ID;
+    if (!point_delete) {
+        return true;
+    }
+    std::string end_key {key};
+    encode_int64(INT64_MAX, &end_key);
+    RangeGetOptions opts;
+    opts.batch_limit = 1;
+    opts.reverse = true;
+    std::unique_ptr<RangeGetIterator> it;
+    auto err = txn->get(key, end_key, &it, opts);
+    if (err != TxnErrorCode::TXN_OK) {
+        code = cast_as<ErrCategory::READ>(err);
+        msg = fmt::format(
+                "failed to get the last delete bitmap blob key, err={}, 
tablet_id={}, key={}", err,
+                request->tablet_id(), hex(key));
+        return false;
+    }
+
+    delete_bitmap_exists = it->has_next();
+    max_blob_sequence.reset();
+    if (!delete_bitmap_exists) {
+        return true;
+    }
+    auto max_key = it->next().first;
+    if (max_key.size() <= key.size()) {
+        DCHECK_EQ(max_key, key);
+        return true;
+    }
+    std::string origin_key;
+    uint8_t version = 0;
+    uint16_t sequence = 0;
+    if (!decode_blob_key(max_key, &origin_key, &version, &sequence)) 
[[unlikely]] {
+        code = MetaServiceCode::UNDEFINED_ERR;
+        msg = fmt::format("failed to decode delete bitmap blob key, 
tablet_id={}, key={}",
+                          request->tablet_id(), hex(max_key));
+        return false;
+    }
+    DCHECK_EQ(origin_key, key);
+    DCHECK_EQ(version, 0);

Review Comment:
   dcheck is not enough
   we cannot take any error silently in release version



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