fix backup statistic not accurate issue
This commit is contained in:
@ -423,47 +423,17 @@ int ObBackupDataLSTaskMgr::finish_(int64_t &finish_cnt)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObBackupDataLSTaskMgr::statistic_info(
|
||||
int ObBackupDataLSTaskMgr::mark_ls_task_info_final(
|
||||
ObBackupLeaseService &lease_service,
|
||||
common::ObISQLClient &sql_proxy,
|
||||
const ObBackupLSTaskAttr &ls_attr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArray<ObBackupLSTaskInfoAttr> stats_array;
|
||||
ObBackupStats stats;
|
||||
stats.assign(ls_attr.stats_);
|
||||
share::ObBackupDataType backup_data_type;
|
||||
if (ObBackupDataTaskType::Type::BACKUP_PLUS_ARCHIVE_LOG == ls_attr.task_type_.type_
|
||||
|| ObBackupDataTaskType::Type::BACKUP_BUILD_INDEX == ls_attr.task_type_.type_) { // do nothing
|
||||
} else if (OB_FAIL(ObBackupLSTaskInfoOperator::get_statistics_info(sql_proxy, ls_attr.task_id_, ls_attr.tenant_id_,
|
||||
ls_attr.ls_id_, ls_attr.turn_id_, ls_attr.retry_id_, stats_array))) {
|
||||
LOG_WARN("[DATA_BACKUP]failed to get stats array", K(ret), K(ls_attr));
|
||||
} else {
|
||||
for (int i = 0; OB_SUCC(ret) && i < stats_array.count(); ++i) {
|
||||
const ObBackupLSTaskInfoAttr &tmp_stats = stats_array.at(i);
|
||||
if (!tmp_stats.is_valid()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("[DATA_BACKUP]invalid ls task info stats", K(tmp_stats));
|
||||
} else {
|
||||
stats.input_bytes_ += tmp_stats.input_bytes_;
|
||||
stats.output_bytes_ += tmp_stats.output_bytes_;
|
||||
stats.macro_block_count_ += tmp_stats.macro_block_count_;
|
||||
stats.finish_macro_block_count_ += tmp_stats.finish_macro_block_count_;
|
||||
stats.extra_bytes_ += tmp_stats.extra_bytes_;
|
||||
stats.finish_file_count_ += tmp_stats.file_count_;
|
||||
if (share::ObBackupDataType::BackupDataType::BACKUP_MINOR == tmp_stats.backup_data_type_
|
||||
|| share::ObBackupDataType::BackupDataType::BACKUP_SYS == tmp_stats.backup_data_type_) {
|
||||
stats.tablet_count_ += tmp_stats.tablet_count_;
|
||||
stats.finish_tablet_count_ += tmp_stats.finish_tablet_count_;
|
||||
}
|
||||
}
|
||||
}
|
||||
share::ObBackupDataType backup_data_type;
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(lease_service.check_lease())) {
|
||||
LOG_WARN("[DATA_BACKUP]failed to check lease", K(ret));
|
||||
} else if (!stats_array.empty() && OB_FAIL(ObBackupLSTaskOperator::update_stats_(
|
||||
sql_proxy, ls_attr.task_id_, ls_attr.tenant_id_, ls_attr.ls_id_, stats))) {
|
||||
LOG_WARN("[DATA_BACKUP]failed to update stats", K(ret));
|
||||
} else if (!ls_attr.task_type_.is_backup_data()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ls_attr.task_type_.get_backup_data_type(backup_data_type))) {
|
||||
@ -472,7 +442,6 @@ int ObBackupDataLSTaskMgr::statistic_info(
|
||||
ls_attr.turn_id_, ls_attr.retry_id_, backup_data_type, sql_proxy))) {
|
||||
LOG_WARN("[DATA_BACKUP]failed to update ls task info final to True", K(ret), K(ls_attr));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
const int64_t start_turn_id,
|
||||
const int64_t turn_id,
|
||||
const int64_t retry_id);
|
||||
static int statistic_info(ObBackupLeaseService &lease_service,
|
||||
static int mark_ls_task_info_final(ObBackupLeaseService &lease_service,
|
||||
common::ObISQLClient &sql_proxy,
|
||||
const share::ObBackupLSTaskAttr &ls_attr);
|
||||
static int update_black_server(ObBackupLeaseService &lease_service,
|
||||
|
||||
@ -893,9 +893,8 @@ int ObBackupDataScheduler::handle_execute_over(
|
||||
} else {
|
||||
if (OB_FAIL(ObBackupLSTaskOperator::get_ls_task(trans, true/*for update*/, task->get_task_id(), task->get_tenant_id(), ls_id, ls_attr))) {
|
||||
LOG_WARN("[DATA_BACKUP]failed to get log stream task", K(ret), KPC(task));
|
||||
} else if (OB_FAIL(ObBackupDataLSTaskMgr::statistic_info(*lease_service_, trans, ls_attr))) {
|
||||
// TODO: delete this when observer support the function that backup progress statistics
|
||||
LOG_WARN("[DATA_BACKUP]failed to update statistic infomation of ls task", K(ret), K(ls_attr));
|
||||
} else if (OB_FAIL(ObBackupDataLSTaskMgr::mark_ls_task_info_final(*lease_service_, trans, ls_attr))) {
|
||||
LOG_WARN("[DATA_BACKUP]failed to update ls task info final", K(ret), K(ls_attr));
|
||||
} else if (OB_FALSE_IT(ls_attr.end_ts_ = ObTimeUtility::current_time())) {
|
||||
} else if (ObBackupTaskStatus::Status::DOING == ls_attr.status_.status_) {
|
||||
ObBackupTaskStatus next_status(ObBackupTaskStatus::Status::FINISH);
|
||||
|
||||
@ -173,6 +173,10 @@ public:
|
||||
const blocksstable::ObLogicMacroBlockId &logic_id, ObBackupMacroBlockIndex ¯o_index);
|
||||
int write_meta_data(const blocksstable::ObBufferReader &meta_data, const common::ObTabletID &tablet_id,
|
||||
const ObBackupMetaType &meta_type, ObBackupMetaIndex &meta_index);
|
||||
int64_t get_file_size() const
|
||||
{
|
||||
return file_write_ctx_.get_file_size();
|
||||
}
|
||||
int close();
|
||||
|
||||
private:
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "storage/ob_storage_rpc.h"
|
||||
#include "storage/blocksstable/ob_logic_macro_id.h"
|
||||
#include "share/backup/ob_backup_struct.h"
|
||||
#include "share/backup/ob_backup_data_table_operator.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace oceanbase::blocksstable;
|
||||
@ -2693,8 +2694,7 @@ int ObLSBackupDataTask::do_backup_macro_block_data_()
|
||||
} else if (OB_FAIL(ls_backup_ctx_->stat_mgr_.add_bytes(backup_data_type_, macro_index.length_))) {
|
||||
LOG_WARN("failed to add bytes", K(ret));
|
||||
} else {
|
||||
backup_stat_.input_bytes_ += buffer_reader.capacity();
|
||||
backup_stat_.output_bytes_ += buffer_reader.capacity();
|
||||
backup_stat_.input_bytes_ += OB_DEFAULT_MACRO_BLOCK_SIZE;
|
||||
backup_stat_.finish_macro_block_count_ += 1;
|
||||
}
|
||||
}
|
||||
@ -2743,7 +2743,6 @@ int ObLSBackupDataTask::do_backup_meta_data_()
|
||||
LOG_WARN("failed to mark backup item finished", K(ret), K(item), K(physical_id));
|
||||
} else {
|
||||
backup_stat_.input_bytes_ += buffer_reader.capacity();
|
||||
backup_stat_.output_bytes_ += buffer_reader.capacity();
|
||||
if (PROVIDER_ITEM_TABLET_META == item.get_item_type()) {
|
||||
backup_stat_.finish_tablet_count_ += 1;
|
||||
ls_backup_ctx_->stat_mgr_.add_tablet_meta(backup_data_type_, item.get_tablet_id());
|
||||
@ -2801,6 +2800,7 @@ int ObLSBackupDataTask::finish_task_in_order_()
|
||||
LOG_WARN("failed to wait task", K(ret), K_(task_id));
|
||||
} else if (OB_FAIL(backup_data_ctx_.close())) {
|
||||
LOG_WARN("failed to close backup data ctx", K(ret), K_(param));
|
||||
} else if (OB_FALSE_IT(backup_stat_.output_bytes_ = backup_data_ctx_.get_file_size())) {
|
||||
} else if (OB_FAIL(report_ls_backup_task_info_(backup_stat_))) {
|
||||
LOG_WARN("failed to report ls backup task info", K(ret));
|
||||
} else if (OB_FAIL(ls_backup_ctx_->finish_task(task_id_))) {
|
||||
@ -2823,7 +2823,12 @@ int ObLSBackupDataTask::report_ls_backup_task_info_(const ObLSBackupStat &stat)
|
||||
LOG_WARN("failed to start transaction", K(ret), K(param_));
|
||||
} else {
|
||||
ObLSBackupStat new_stat;
|
||||
if (OB_FAIL(ObLSBackupOperator::get_backup_ls_task_info(param_.tenant_id_,
|
||||
share::ObBackupStats new_task_stat;
|
||||
share::ObBackupLSTaskAttr ls_task_attr;
|
||||
if (OB_FAIL(share::ObBackupLSTaskOperator::get_ls_task(trans, for_update,
|
||||
param_.job_desc_.task_id_, param_.tenant_id_, param_.ls_id_, ls_task_attr))) {
|
||||
LOG_WARN("failed to get ls task", K(ret), K_(param));
|
||||
} else if (OB_FAIL(ObLSBackupOperator::get_backup_ls_task_info(param_.tenant_id_,
|
||||
param_.job_desc_.task_id_,
|
||||
param_.ls_id_,
|
||||
param_.turn_id_,
|
||||
@ -2837,8 +2842,13 @@ int ObLSBackupDataTask::report_ls_backup_task_info_(const ObLSBackupStat &stat)
|
||||
LOG_INFO("can not update if final", K(ls_task_info), K(stat));
|
||||
} else if (ls_task_info.max_file_id_ + 1 != stat.file_id_) {
|
||||
LOG_INFO("can not update if file id is not consecutive", K(ls_task_info), K(stat));
|
||||
} else if (OB_FAIL(update_task_stat_(ls_task_attr.stats_, stat, new_task_stat))) {
|
||||
LOG_WARN("failed to update task stat", K(ret), K(ls_task_attr));
|
||||
} else if (OB_FAIL(update_task_info_stat_(ls_task_info, stat, new_stat))) {
|
||||
LOG_WARN("failed to update task info stat", K(ret), K(ls_task_info), K(stat));
|
||||
} else if (OB_FAIL(share::ObBackupLSTaskOperator::update_stats_(trans, param_.job_desc_.task_id_,
|
||||
param_.tenant_id_, param_.ls_id_, new_task_stat))) {
|
||||
LOG_WARN("failed to update stat", K(ret), K(param_));
|
||||
} else if (OB_FAIL(ObLSBackupOperator::report_ls_backup_task_info(param_.tenant_id_,
|
||||
param_.job_desc_.task_id_,
|
||||
param_.turn_id_,
|
||||
@ -2861,6 +2871,25 @@ int ObLSBackupDataTask::report_ls_backup_task_info_(const ObLSBackupStat &stat)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// TODO(yangyi.yyy): make tablet count accurate
|
||||
int ObLSBackupDataTask::update_task_stat_(const share::ObBackupStats &old_backup_stat, const ObLSBackupStat &ls_stat,
|
||||
share::ObBackupStats &new_backup_stat)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
new_backup_stat.input_bytes_ = old_backup_stat.input_bytes_ + ls_stat.input_bytes_;
|
||||
new_backup_stat.output_bytes_ = old_backup_stat.output_bytes_ + ls_stat.output_bytes_;
|
||||
new_backup_stat.macro_block_count_ = old_backup_stat.macro_block_count_ + ls_stat.finish_macro_block_count_;
|
||||
new_backup_stat.finish_macro_block_count_ = old_backup_stat.finish_macro_block_count_ + ls_stat.finish_macro_block_count_;
|
||||
if (backup_data_type_.is_minor_backup() || backup_data_type_.is_sys_backup()) {
|
||||
new_backup_stat.tablet_count_ = old_backup_stat.tablet_count_ + ls_stat.finish_tablet_count_;
|
||||
new_backup_stat.finish_tablet_count_ = old_backup_stat.finish_tablet_count_ + ls_stat.finish_tablet_count_;
|
||||
} else {
|
||||
new_backup_stat.tablet_count_ = old_backup_stat.tablet_count_;
|
||||
new_backup_stat.finish_tablet_count_ = old_backup_stat.finish_tablet_count_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLSBackupDataTask::update_task_info_stat_(
|
||||
const ObBackupLSTaskInfo &task_info, const ObLSBackupStat &stat, ObLSBackupStat &new_stat)
|
||||
{
|
||||
|
||||
@ -538,6 +538,8 @@ private:
|
||||
const ObBackupProviderItem &item, ObTabletMetaReaderType &reader_type, ObBackupMetaType &meta_type);
|
||||
int finish_task_in_order_();
|
||||
int report_ls_backup_task_info_(const ObLSBackupStat &stat);
|
||||
int update_task_stat_(const share::ObBackupStats &old_backup_stat, const ObLSBackupStat &ls_stat,
|
||||
share::ObBackupStats &new_backup_stat);
|
||||
int update_task_info_stat_(const ObBackupLSTaskInfo &task_info, const ObLSBackupStat &stat, ObLSBackupStat &new_stat);
|
||||
int do_generate_next_task_();
|
||||
int check_disk_space_();
|
||||
|
||||
Reference in New Issue
Block a user