zhannngchen commented on code in PR #47281: URL: https://github.com/apache/doris/pull/47281#discussion_r1924926131
########## cloud/src/meta-service/meta_service.cpp: ########## @@ -2222,47 +2222,95 @@ void MetaServiceImpl::get_delete_bitmap_update_lock(google::protobuf::RpcControl // these steps can be done in different fdb txns StopWatch read_stats_sw; - err = txn_kv_->create_txn(&txn); - if (err != TxnErrorCode::TXN_OK) { - code = cast_as<ErrCategory::CREATE>(err); - msg = "failed to init txn"; - return; - } + if (!config::enable_batch_get_mow_tablet_stats) { + err = txn_kv_->create_txn(&txn); + if (err != TxnErrorCode::TXN_OK) { + code = cast_as<ErrCategory::CREATE>(err); + msg = "failed to init txn"; + return; + } + + for (const auto& tablet_idx : request->tablet_indexes()) { + TabletStatsPB tablet_stat; + std::string stats_key = + stats_tablet_key({instance_id, tablet_idx.table_id(), tablet_idx.index_id(), + tablet_idx.partition_id(), tablet_idx.tablet_id()}); + std::string stats_val; + TxnErrorCode err = txn->get(stats_key, &stats_val); + TEST_SYNC_POINT_CALLBACK( + "get_delete_bitmap_update_lock.get_compaction_cnts_inject_error", &err); + if (err == TxnErrorCode::TXN_TOO_OLD) { + code = MetaServiceCode::OK; + err = txn_kv_->create_txn(&txn); + if (err != TxnErrorCode::TXN_OK) { + code = cast_as<ErrCategory::CREATE>(err); + ss << "failed to init txn when get tablet stats"; + msg = ss.str(); + return; + } + err = txn->get(stats_key, &stats_val); + } + if (err != TxnErrorCode::TXN_OK) { + code = cast_as<ErrCategory::READ>(err); + msg = fmt::format("failed to get tablet stats, err={} tablet_id={}", err, + tablet_idx.tablet_id()); + return; + } + if (!tablet_stat.ParseFromArray(stats_val.data(), stats_val.size())) { + code = MetaServiceCode::PROTOBUF_PARSE_ERR; + msg = fmt::format("marformed tablet stats value, key={}", hex(stats_key)); + return; + } + response->add_base_compaction_cnts(tablet_stat.base_compaction_cnt()); + response->add_cumulative_compaction_cnts(tablet_stat.cumulative_compaction_cnt()); + response->add_cumulative_points(tablet_stat.cumulative_point()); + } + } else { + int32_t batch_size = config::max_mow_tablet_stat_num_per_batch; Review Comment: +1, #45206 added many unit tests, this PR should update these tests as well -- 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