gavinchou commented on code in PR #45206: URL: https://github.com/apache/doris/pull/45206#discussion_r1881927940
########## cloud/src/meta-service/meta_service.cpp: ########## @@ -2193,6 +2169,73 @@ void MetaServiceImpl::get_delete_bitmap_update_lock(google::protobuf::RpcControl msg = ss.str(); return; } + + bool require_tablet_stats = + request->has_require_compaction_stats() ? request->require_compaction_stats() : false; + if (require_tablet_stats) { + // this request is from fe when it commits txn for MOW table, we send the compaction stats + // along with the GetDeleteBitmapUpdateLockResponse which will be sent to BE later to let + // BE eliminate unnecessary sync_rowsets() calls if possible + + // 1. hold the delete bitmap update lock in MS(update lock_info.lock_id to current load's txn id) + // 2. read tablets' stats + // 3. check whether we still hold the delete bitmap update lock + // these steps can be done in different fdb txns + + err = txn_kv_->create_txn(&txn); + if (err != TxnErrorCode::TXN_OK) { + code = cast_as<ErrCategory::CREATE>(err); + msg = "failed to init txn"; + return; + } + + int64_t total_retry = 0; + for (const auto& tablet_index : request->tablet_indexes()) { + TabletIndexPB idx(tablet_index); + TabletStatsPB tablet_stat; + int64_t retry = 0; + internal_get_tablet_stats(code, msg, txn.get(), instance_id, idx, tablet_stat, false); + while (retry < 3 && total_retry < 20 && code == MetaServiceCode::KV_TXN_TOO_OLD) { + retry++; + total_retry++; + + 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, retry=" << retry; + msg = ss.str(); + return; + } + internal_get_tablet_stats(code, msg, txn.get(), instance_id, idx, tablet_stat, + false); + LOG(INFO) << "retry get tablet stats, instance_id=" << instance_id + << ", tablet=" << idx.tablet_id() << ", retry=" << retry + << ", total_retry=" << total_retry; + } + if (code != MetaServiceCode::OK) { + response->clear_base_compaction_cnts(); + response->clear_cumulative_compaction_cnts(); + response->clear_cumulative_points(); + LOG_WARNING( + "failed to get tablet stats when internal_get_tablet_stats, " + "lock_id={}, initiator={}, tablet_id={}, msg={}", + request->lock_id(), request->initiator(), tablet_index.tablet_id(), msg); + 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()); + } + + if (!check_delete_bitmap_lock(code, msg, ss, txn, instance_id, table_id, request->lock_id(), + request->initiator())) { + LOG(WARNING) << "failed to check delete bitmap lock after get tablet stats, table_id=" + << table_id << " request lock_id=" << request->lock_id() + << " request initiator=" << request->initiator() << " msg " << msg; + return; Review Comment: redundant `return` -- 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