zhannngchen commented on code in PR #44154: URL: https://github.com/apache/doris/pull/44154#discussion_r1846488098
########## cloud/src/recycler/checker.cpp: ########## @@ -748,4 +760,341 @@ int InstanceChecker::do_inverted_check() { return num_file_leak > 0 ? 1 : check_ret; } +std::string InstanceChecker::RowsetDigest::to_string() const { + return fmt::format("rowset_id={}, version=[{}-{}]", rowset_id, version.first, version.second); +} + +int InstanceChecker::check_delete_bitmap_integrity(int64_t tablet_id) { + // number of rowsets which doesn't have a delete bitmap in MS + int64_t abnormal_rowsets_num {0}; + + std::vector<RowsetDigest> tablet_rowsets {}; + // Get all visible rowsets of this tablet + auto collect_cb = [&tablet_rowsets](const doris::RowsetMetaCloudPB& rowset) { + tablet_rowsets.emplace_back( + rowset.rowset_id_v2(), + std::make_pair<int64_t, int64_t>(rowset.start_version(), rowset.end_version())); + ; + }; + if (int ret = collect_tablet_rowsets(tablet_id, collect_cb); ret != 0) { + return ret; + } + + // Check + std::unique_ptr<Transaction> txn; + TxnErrorCode err = txn_kv_->create_txn(&txn); + if (err != TxnErrorCode::TXN_OK) { + LOG(WARNING) << "failed to create txn"; + return -1; + } + + for (const auto& rowset : tablet_rowsets) { + if (rowset.version.second <= 1) { + // skip dummy rowset [0-1] + continue; + } + std::string rowset_id = rowset.rowset_id; + auto begin = meta_delete_bitmap_key({instance_id_, tablet_id, rowset_id, 0, 0}); + auto end = meta_delete_bitmap_key({instance_id_, tablet_id, rowset_id, + std::numeric_limits<int64_t>::max(), + std::numeric_limits<int64_t>::max()}); + std::unique_ptr<RangeGetIterator> it; + TxnErrorCode err = txn->get(begin, end, &it); + if (err != TxnErrorCode::TXN_OK) { + LOG(WARNING) << "failed to get delete bitmap kv for rowset_id=" << rowset.rowset_id + << ", err=" << err; + return -1; + } + if (!it->has_next()) { + TEST_SYNC_POINT_CALLBACK( + "InstanceChecker::check_delete_bitmap_integrity.get_abnormal_rowset", + &tablet_id, &rowset_id); + ++abnormal_rowsets_num; Review Comment: delete bitmap on a rowset might be empty, as discussed, we can't check delete bitmap by rowset -- 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