[enhancement](publish) add metic publish version cost (#13522)
Co-authored-by: yixiutt <yixiu@selectdb.com>
This commit is contained in:
@ -1026,38 +1026,8 @@ void StorageEngine::notify_listeners() {
|
||||
}
|
||||
|
||||
Status StorageEngine::execute_task(EngineTask* task) {
|
||||
auto lock_related_tablets = [&]() -> std::vector<std::unique_lock<std::shared_mutex>> {
|
||||
// add write lock to all related tablets
|
||||
std::vector<TabletInfo> tablet_infos;
|
||||
task->get_related_tablets(&tablet_infos);
|
||||
sort(tablet_infos.begin(), tablet_infos.end());
|
||||
std::vector<TabletSharedPtr> related_tablets;
|
||||
std::vector<std::unique_lock<std::shared_mutex>> wrlocks;
|
||||
for (TabletInfo& tablet_info : tablet_infos) {
|
||||
TabletSharedPtr tablet = _tablet_manager->get_tablet(tablet_info.tablet_id);
|
||||
if (tablet != nullptr) {
|
||||
related_tablets.push_back(tablet);
|
||||
wrlocks.push_back(std::unique_lock<std::shared_mutex>(tablet->get_header_lock()));
|
||||
} else {
|
||||
LOG(WARNING) << "could not get tablet before prepare tabletid: "
|
||||
<< tablet_info.tablet_id;
|
||||
}
|
||||
}
|
||||
return wrlocks;
|
||||
};
|
||||
|
||||
{
|
||||
auto wrlocks = lock_related_tablets();
|
||||
RETURN_IF_ERROR(task->prepare());
|
||||
}
|
||||
|
||||
// do execute work without lock
|
||||
RETURN_IF_ERROR(task->execute());
|
||||
|
||||
{
|
||||
auto wrlocks = lock_related_tablets();
|
||||
return task->finish();
|
||||
}
|
||||
return task->finish();
|
||||
}
|
||||
|
||||
// check whether any unused rowsets's id equal to rowset_id
|
||||
|
||||
@ -59,6 +59,7 @@ void EnginePublishVersionTask::notify() {
|
||||
Status EnginePublishVersionTask::finish() {
|
||||
Status res = Status::OK();
|
||||
int64_t transaction_id = _publish_version_req.transaction_id;
|
||||
OlapStopWatch watch;
|
||||
VLOG_NOTICE << "begin to process publish version. transaction_id=" << transaction_id;
|
||||
|
||||
// each partition
|
||||
@ -181,7 +182,7 @@ Status EnginePublishVersionTask::finish() {
|
||||
}
|
||||
|
||||
LOG(INFO) << "finish to publish version on transaction."
|
||||
<< "transaction_id=" << transaction_id
|
||||
<< "transaction_id=" << transaction_id << ", cost(us): " << watch.get_elapse_time_us()
|
||||
<< ", error_tablet_size=" << _error_tablet_ids->size() << ", res=" << res.to_string();
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -31,12 +31,8 @@ namespace doris {
|
||||
// add "Engine" as task prefix to prevent duplicate name with agent task
|
||||
class EngineTask {
|
||||
public:
|
||||
// use olap_status not agent_status, because the task is very close to engine
|
||||
virtual Status prepare() { return Status::OK(); }
|
||||
virtual Status execute() { return Status::OK(); }
|
||||
virtual Status finish() { return Status::OK(); }
|
||||
virtual Status cancel() { return Status::OK(); }
|
||||
virtual void get_related_tablets(std::vector<TabletInfo>* tablet_infos) {}
|
||||
};
|
||||
|
||||
} // end namespace doris
|
||||
|
||||
Reference in New Issue
Block a user