Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukang-Lian committed Nov 20, 2024
1 parent 99d8184 commit e9a454c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
1 change: 1 addition & 0 deletions cloud/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,5 @@ CONF_Int32(max_tablet_index_num_per_batch, "1000");
CONF_mInt64(max_num_aborted_txn, "100");

CONF_Bool(enable_check_instance_id, "true");
CONF_Bool(enable_concurrency_get_tablet_stats, "false");
} // namespace doris::cloud::config
50 changes: 32 additions & 18 deletions cloud/src/meta-service/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1618,31 +1618,45 @@ void MetaServiceImpl::get_tablet_stats(::google::protobuf::RpcController* contro
}
RPC_RATE_LIMIT(get_tablet_stats)

std::unique_ptr<Transaction> txn;
for (auto& i : request->tablet_idx()) {
TabletIndexPB idx(i);
// FIXME(plat1ko): Get all tablet stats in one txn
if (!config::enable_concurrency_get_tablet_stats) {
std::unique_ptr<Transaction> txn;
for (auto& i : request->tablet_idx()) {
TabletIndexPB idx(i);
// FIXME(plat1ko): Get all tablet stats in one txn
TxnErrorCode err = txn_kv_->create_txn(&txn);
if (err != TxnErrorCode::TXN_OK) {
code = cast_as<ErrCategory::CREATE>(err);
msg = fmt::format("failed to create txn, tablet_id={}", idx.tablet_id());
return;
}
if (!(/* idx.has_db_id() && */ idx.has_table_id() && idx.has_index_id() &&
idx.has_partition_id() && i.has_tablet_id())) {
get_tablet_idx(code, msg, txn.get(), instance_id, idx.tablet_id(), idx);
if (code != MetaServiceCode::OK) return;
}
auto tablet_stats = response->add_tablet_stats();
internal_get_tablet_stats(code, msg, txn.get(), instance_id, idx, *tablet_stats, true);
if (code != MetaServiceCode::OK) {
response->clear_tablet_stats();
break;
}
#ifdef NDEBUG
// Force data size >= 0 to reduce the losses caused by bugs
if (tablet_stats->data_size() < 0) tablet_stats->set_data_size(0);
#endif
}
} else {
std::unique_ptr<Transaction> txn;
TxnErrorCode err = txn_kv_->create_txn(&txn);
if (err != TxnErrorCode::TXN_OK) {
code = cast_as<ErrCategory::CREATE>(err);
msg = fmt::format("failed to create txn, tablet_id={}", idx.tablet_id());
return;
}
if (!(/* idx.has_db_id() && */ idx.has_table_id() && idx.has_index_id() &&
idx.has_partition_id() && i.has_tablet_id())) {
get_tablet_idx(code, msg, txn.get(), instance_id, idx.tablet_id(), idx);
if (code != MetaServiceCode::OK) return;
for (auto& i : request->tablet_idx()) {
}
auto tablet_stats = response->add_tablet_stats();
internal_get_tablet_stats(code, msg, txn.get(), instance_id, idx, *tablet_stats, true);
if (code != MetaServiceCode::OK) {
response->clear_tablet_stats();
break;
}
#ifdef NDEBUG
// Force data size >= 0 to reduce the losses caused by bugs
if (tablet_stats->data_size() < 0) tablet_stats->set_data_size(0);
#endif
get_batch_tablet_idx();
internal_get_batch_tablet_stats();
}
}

Expand Down

0 comments on commit e9a454c

Please sign in to comment.