diff --git a/src/share/restore/ob_import_table_persist_helper.cpp b/src/share/restore/ob_import_table_persist_helper.cpp index 597bd78ade..32d1c81193 100644 --- a/src/share/restore/ob_import_table_persist_helper.cpp +++ b/src/share/restore/ob_import_table_persist_helper.cpp @@ -126,7 +126,7 @@ int ObImportTableJobPersistHelper::advance_status( LOG_WARN("failed to add column", K(ret)); } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_RESULT, job.get_result().get_result_str()))) { LOG_WARN("failed to add column", K(ret)); - } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_COMMENT, job.get_result().get_comment()))) { + } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(job.get_result().get_comment_str())))) { LOG_WARN("failed to add column", K(ret)); } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_END_TS, job.get_end_ts()))) { LOG_WARN("failed to add column", K(ret)); @@ -364,7 +364,7 @@ int ObImportTableTaskPersistHelper::advance_status( LOG_WARN("failed to add column", K(ret)); } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_RESULT, task.get_result().get_result_str()))) { LOG_WARN("failed to add column", K(ret)); - } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_COMMENT, task.get_result().get_comment()))) { + } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(task.get_result().get_comment_str())))) { LOG_WARN("failed to add column", K(ret)); } else if (OB_FAIL(dml.add_column(OB_STR_STATUS, next_status.get_str()))) { LOG_WARN("failed to add column", K(ret)); diff --git a/src/share/restore/ob_import_table_struct.cpp b/src/share/restore/ob_import_table_struct.cpp index cb7b8a442b..e9764598db 100644 --- a/src/share/restore/ob_import_table_struct.cpp +++ b/src/share/restore/ob_import_table_struct.cpp @@ -422,7 +422,7 @@ int ObImportTableTask::fill_dml(share::ObDMLSqlSplicer &dml) const if (OB_SUCC(ret) && status_.is_finish()) { if (FAILEDx(dml.add_column(OB_STR_RESULT, result_.get_result_str()))) { LOG_WARN("failed to add column", K(ret)); - } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, result_.get_comment()))) { + } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(result_.get_comment_str())))) { LOG_WARN("failed to add column", K(ret)); } } @@ -726,7 +726,7 @@ int ObImportTableJob::fill_dml(share::ObDMLSqlSplicer &dml) const LOG_WARN("failed to add column", K(ret)); } else if (OB_FAIL(dml.add_column("import_all", import_all))) { LOG_WARN("failed to add column", K(ret)); - } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, result_.get_comment()))) { + } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(result_.get_comment())))) { LOG_WARN("failed to add column", K(ret)); } FILL_INT_COLUMN(initiator_tenant_id) @@ -1298,7 +1298,7 @@ int ObRecoverTableJob::fill_dml(share::ObDMLSqlSplicer &dml) const if (OB_SUCC(ret) && status_.is_finish()) { if (OB_FAIL(dml.add_column(OB_STR_RESULT, result_.get_result_str()))) { LOG_WARN("failed to add column", K(ret)); - } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, result_.get_comment()))) { + } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(result_.get_comment())))) { LOG_WARN("failed to add column", K(ret)); } } diff --git a/src/share/restore/ob_import_table_struct.h b/src/share/restore/ob_import_table_struct.h index 8125d5ffcf..f0fe2b816f 100644 --- a/src/share/restore/ob_import_table_struct.h +++ b/src/share/restore/ob_import_table_struct.h @@ -34,6 +34,7 @@ public: void reset(); const char *get_result_str() const { return is_succeed_ ? "SUCCESS" : "FAILED"; } const char *get_comment() const { return comment_.ptr(); } + const ObString get_comment_str() const { return comment_.str(); } bool is_succeed() const { return is_succeed_; } bool is_comment_setted() const { return !comment_.is_empty(); } ObImportResult &operator=(const ObImportResult &result); diff --git a/src/share/restore/ob_recover_table_persist_helper.cpp b/src/share/restore/ob_recover_table_persist_helper.cpp index 40ba6cbb63..283c28d2ce 100644 --- a/src/share/restore/ob_recover_table_persist_helper.cpp +++ b/src/share/restore/ob_recover_table_persist_helper.cpp @@ -119,7 +119,7 @@ int ObRecoverTablePersistHelper::advance_status( LOG_WARN("failed to add column", K(ret)); } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_RESULT, job.get_result().get_result_str()))) { LOG_WARN("failed to add column", K(ret)); - } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_COMMENT, job.get_result().get_comment()))) { + } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(job.get_result().get_comment_str())))) { LOG_WARN("failed to add column", K(ret)); } else if (next_status.is_finish() && OB_FAIL(dml.add_column(OB_STR_END_TS, job.get_end_ts()))) { LOG_WARN("failed to add column", K(ret)); diff --git a/src/share/restore/ob_restore_persist_helper.cpp b/src/share/restore/ob_restore_persist_helper.cpp index 7c1cf9d4a3..8c177f9ed7 100644 --- a/src/share/restore/ob_restore_persist_helper.cpp +++ b/src/share/restore/ob_restore_persist_helper.cpp @@ -220,7 +220,7 @@ int ObLSHisRestorePersistInfo::fill_dml(share::ObDMLSqlSplicer &dml) const LOG_WARN("failed to add column", K(ret)); } else if (OB_FAIL(dml.add_column(OB_STR_RESULT, result_))) { LOG_WARN("failed to add column", K(ret)); - } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, comment_.ptr()))) { + } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(comment_.string())))) { LOG_WARN("failed to add column", K(ret)); } @@ -371,7 +371,7 @@ int ObLSRestoreProgressPersistInfo::fill_dml(share::ObDMLSqlSplicer &dml) const LOG_WARN("failed to add column", K(ret)); } else if (OB_FAIL(dml.add_column(OB_STR_RESULT, result_))) { LOG_WARN("failed to add column", K(ret)); - } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, comment_.ptr()))) { + } else if (OB_FAIL(dml.add_column(OB_STR_COMMENT, ObHexEscapeSqlStr(comment_.str())))) { LOG_WARN("failed to add column", K(ret)); } diff --git a/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp b/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp index bbc1612643..cee20e45aa 100644 --- a/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp +++ b/src/storage/high_availability/ob_storage_ha_tablet_builder.cpp @@ -394,7 +394,9 @@ int ObStorageHATabletsBuilder::update_pending_tablets_with_remote() } else if (ObCopyTabletStatus::TABLET_NOT_EXIST == tablet_info.status_) { // If remote tablet is not exist, update local tablet from PENDING to // UNDEFINED. - if (OB_FAIL(ls->update_tablet_restore_status(tablet_info.tablet_id_, ObTabletRestoreStatus::STATUS::UNDEFINED))) { + if (OB_FAIL(ls->update_tablet_restore_status(tablet_info.tablet_id_, + ObTabletRestoreStatus::STATUS::UNDEFINED, + true/* need reset transfer flag */))) { LOG_WARN("failed to update tablet restore status to UNDEFINED", K(ret), K(tablet_info)); } else { LOG_INFO("update tablet restore status to UNDEFINED", K(tablet_info)); diff --git a/src/storage/high_availability/ob_tablet_group_restore.cpp b/src/storage/high_availability/ob_tablet_group_restore.cpp index 265db9cb5c..116253cb2d 100644 --- a/src/storage/high_availability/ob_tablet_group_restore.cpp +++ b/src/storage/high_availability/ob_tablet_group_restore.cpp @@ -40,7 +40,7 @@ static int update_deleted_and_undefine_tablet(ObLS &ls, const ObTabletID &tablet } else { LOG_WARN("failed to update expected status to DELETED", K(ret), K(expected_status), K(tablet_id)); } - } else if (OB_FAIL(ls.update_tablet_restore_status(tablet_id, restore_status))) { + } else if (OB_FAIL(ls.update_tablet_restore_status(tablet_id, restore_status, true/* need reset transfer flag */))) { if (OB_TABLET_NOT_EXIST == ret) { LOG_INFO("restore tablet maybe deleted, skip update restore status to UNDEFINED", K(ret), K(tablet_id)); ret = OB_SUCCESS; @@ -2787,7 +2787,9 @@ int ObTabletFinishRestoreTask::update_restore_status_() if (OB_FAIL(ObTabletRestoreAction::trans_restore_action_to_restore_status( tablet_restore_ctx_->action_, tablet_restore_status))) { LOG_WARN("failed to trans restore action to restore status", K(ret), KPC(tablet_restore_ctx_)); - } else if (OB_FAIL(ls_->update_tablet_restore_status(tablet_restore_ctx_->tablet_id_, tablet_restore_status))) { + } else if (OB_FAIL(ls_->update_tablet_restore_status(tablet_restore_ctx_->tablet_id_, + tablet_restore_status, + false /* donot reset has transfer table flag */))) { if (OB_TABLET_NOT_EXIST == ret) { LOG_INFO("restore tablet maybe deleted, skip it", K(ret), KPC(tablet_restore_ctx_)); ret = OB_SUCCESS; diff --git a/src/storage/high_availability/ob_transfer_backfill_tx.cpp b/src/storage/high_availability/ob_transfer_backfill_tx.cpp index 6ac5804f20..26a365096c 100644 --- a/src/storage/high_availability/ob_transfer_backfill_tx.cpp +++ b/src/storage/high_availability/ob_transfer_backfill_tx.cpp @@ -164,8 +164,10 @@ int ObTransferWorkerMgr::get_need_backfill_tx_tablets_(ObTransferBackfillTXParam // If source tablet is UNDEFINED, directly set dest tablet EMPTY, but keep // transfer table. Then the restore handler will schedule it to restore minor // without creating remote logical table. + // Remote logical table is no longer relyed needed during physical copy, just reset has tranfser table flag. if (OB_FAIL(dest_ls_->update_tablet_restore_status(tablet->get_tablet_meta().tablet_id_, - ObTabletRestoreStatus::EMPTY))) { + ObTabletRestoreStatus::EMPTY, + true/* need reset tranfser flag */))) { LOG_WARN("fail to set empty", K(ret), KPC(tablet)); } else { dest_ls_->get_ls_restore_handler()->try_record_one_tablet_to_restore(tablet->get_tablet_meta().tablet_id_); diff --git a/src/storage/ls/ob_ls_tablet_service.cpp b/src/storage/ls/ob_ls_tablet_service.cpp index 581202e51b..82deac5693 100644 --- a/src/storage/ls/ob_ls_tablet_service.cpp +++ b/src/storage/ls/ob_ls_tablet_service.cpp @@ -1522,7 +1522,8 @@ int ObLSTabletService::update_tablet_snapshot_version( int ObLSTabletService::update_tablet_restore_status( const common::ObTabletID &tablet_id, - const ObTabletRestoreStatus::STATUS &restore_status) + const ObTabletRestoreStatus::STATUS &restore_status, + const bool need_reset_transfer_flag) { int ret = OB_SUCCESS; ObTabletHandle tablet_handle; @@ -1559,7 +1560,7 @@ int ObLSTabletService::update_tablet_restore_status( LOG_WARN("can not change restore status", K(ret), K(current_status), K(restore_status), KPC(tablet)); } else if (OB_FAIL(tablet->tablet_meta_.ha_status_.set_restore_status(restore_status))) { LOG_WARN("failed to set restore status", K(ret), K(restore_status), KPC(tablet)); - } else if (restore_status == ObTabletRestoreStatus::UNDEFINED + } else if (need_reset_transfer_flag && OB_FALSE_IT((void)tablet->tablet_meta_.reset_transfer_table())) { } else { // TODO(jiahua.cjh) move check valid to tablet init after generate new version tablet. @@ -1572,7 +1573,7 @@ int ObLSTabletService::update_tablet_restore_status( } else if (OB_FAIL(safe_update_cas_tablet(key, disk_addr, tablet_handle, new_tablet_handle, time_guard))) { LOG_WARN("fail to update tablet", K(ret), K(key), K(disk_addr)); } else { - LOG_INFO("succeeded to build new tablet", K(ret), K(key), K(disk_addr), K(restore_status), K(tablet_handle)); + LOG_INFO("succeeded to build new tablet", K(ret), K(key), K(disk_addr), K(restore_status), K(need_reset_transfer_flag), K(tablet_handle)); } if (OB_FAIL(ret)) { diff --git a/src/storage/ls/ob_ls_tablet_service.h b/src/storage/ls/ob_ls_tablet_service.h index 75c8fad0a9..c561644ed7 100644 --- a/src/storage/ls/ob_ls_tablet_service.h +++ b/src/storage/ls/ob_ls_tablet_service.h @@ -250,7 +250,8 @@ public: const SCN scn); int update_tablet_restore_status( const common::ObTabletID &tablet_id, - const ObTabletRestoreStatus::STATUS &restore_status); + const ObTabletRestoreStatus::STATUS &restore_status, + const bool need_reset_transfer_flag); int update_tablet_ha_data_status( const common::ObTabletID &tablet_id, const ObTabletDataStatus::STATUS &data_status); diff --git a/src/storage/restore/ob_ls_restore_handler.cpp b/src/storage/restore/ob_ls_restore_handler.cpp index f4e2f125ee..7c59f269b7 100644 --- a/src/storage/restore/ob_ls_restore_handler.cpp +++ b/src/storage/restore/ob_ls_restore_handler.cpp @@ -814,13 +814,13 @@ int ObILSRestoreState::deal_failed_restore(const ObLSRestoreResultMgr &result_mg if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("not init", K(ret)); - } else if (OB_FAIL(update_restore_status_(*ls_, next_status))) { - LOG_WARN("failed to update restore status", K(ret), KPC(ls_), K(next_status)); } else if (OB_FAIL(result_mgr.get_comment_str(ls_->get_ls_id(), self_addr_, comment))) { LOG_WARN("fail to get comment str", K(ret)); } else if (OB_FAIL(report_ls_restore_progress_(*ls_, next_status, result_mgr.get_trace_id(), result_mgr.get_result(), comment.ptr()))) { LOG_WARN("fail to report ls restore progress", K(ret)); + } else if (OB_FAIL(update_restore_status_(*ls_, next_status))) { + LOG_WARN("failed to update restore status", K(ret), KPC(ls_), K(next_status)); } else if (OB_FAIL(report_ls_restore_status_(*ls_, next_status))) { LOG_WARN("fail to report ls restore progress", K(ret)); } @@ -2170,7 +2170,9 @@ int ObLSRestoreConsistentScnState::set_empty_for_transfer_tablets_() LOG_INFO("skip tablet which restore status is not full", "tablet_id", tablet->get_tablet_meta().tablet_id_, "ha_status", tablet->get_tablet_meta().ha_status_); - } else if (OB_FAIL(ls_->update_tablet_restore_status(tablet->get_tablet_meta().tablet_id_, restore_status))) { + } else if (OB_FAIL(ls_->update_tablet_restore_status(tablet->get_tablet_meta().tablet_id_, + restore_status, + true/* need reset tranfser flag */))) { LOG_WARN("failed to update tablet restore status to EMPTY", K(ret), KPC(tablet)); } else { LOG_INFO("update tablet restore status to EMPTY",