fix backup report -4016 because ls restore status is 11

This commit is contained in:
oceanoverflow
2023-02-09 14:02:25 +00:00
committed by ob-robot
parent 2bbf0ee9fe
commit 3051928b96
4 changed files with 66 additions and 5 deletions

View File

@ -447,6 +447,7 @@ class ObString;
ACT(BEFORE_MIGRATION_FETCH_TABLET_INFO,)\
ACT(BEFORE_BUILD_TABLET_GROUP_INFO,)\
ACT(BEFORE_RESTORE_SERVICE_PUSH_FETCH_DATA,)\
ACT(AFTER_MIGRATION_REPORT_LS_META_TABLE,)\
ACT(MAX_DEBUG_SYNC_POINT,)
DECLARE_ENUM(ObDebugSyncPoint, debug_sync_point, OB_DEBUG_SYNC_POINT_DEF);

View File

@ -25,6 +25,7 @@
#include "storage/tablet/ob_tablet_iterator.h"
#include "ob_storage_ha_utils.h"
#include "storage/tablet/ob_tablet.h"
#include "share/ls/ob_ls_table_operator.h"
namespace oceanbase
{
@ -938,15 +939,17 @@ int ObStartMigrationTask::process()
} else if (OB_FAIL(try_remove_member_list_())) {
LOG_WARN("failed to try remove member list", K(ret));
} else if (OB_FAIL(deal_with_local_ls_())) {
LOG_WARN("failed to deal with local ls", K(ret), K(*ctx_));
LOG_WARN("failed to deal with local ls", K(ret), KPC(ctx_));
} else if (OB_FAIL(check_ls_need_copy_data_(need_copy_data))) {
LOG_WARN("failed to check ls need copy data", K(ret), KPC(ctx_));
} else if (!need_copy_data) {
//do nothing
} else if (OB_FAIL(report_ls_meta_table_())) {
LOG_WARN("failed to report ls meta table", K(ret), KPC(ctx_));
} else if (OB_FAIL(choose_src_())) {
LOG_WARN("failed to choose src", K(ret), K(*ctx_));
LOG_WARN("failed to choose src", K(ret), KPC(ctx_));
} else if (OB_FAIL(update_ls_())) {
LOG_WARN("failed to update_ls_", K(ret), K(*ctx_));
LOG_WARN("failed to update_ls_", K(ret), KPC(ctx_));
} else if (OB_FAIL(deal_local_restore_ls_(need_generate_dag))) {
LOG_WARN("failed to deal local restore ls", K(ret), KPC(ctx_));
} else if (!need_generate_dag) {
@ -1081,6 +1084,39 @@ int ObStartMigrationTask::deal_with_local_ls_()
return ret;
}
int ObStartMigrationTask::report_ls_meta_table_()
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("start migration task do not init", K(ret));
} else if (OB_ISNULL(ctx_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("ctx should not be null", K(ret));
} else if (ObMigrationOpType::ADD_LS_OP != ctx_->arg_.type_
&& ObMigrationOpType::MIGRATE_LS_OP != ctx_->arg_.type_) {
// do nothing
} else {
const uint64_t tenant_id = ctx_->tenant_id_;
const share::ObLSID &ls_id = ctx_->arg_.ls_id_;
ObLSReplica ls_replica;
share::ObLSTableOperator *lst_operator = GCTX.lst_operator_;
const bool inner_table_only = false;
if (OB_FAIL(GCTX.ob_service_->fill_ls_replica(tenant_id, ls_id, ls_replica))) {
LOG_WARN("failed to fill ls replica", K(ret), K(tenant_id), K(ls_id));
} else if (OB_FAIL(lst_operator->update(ls_replica, inner_table_only))) {
LOG_WARN("failed to update ls meta table", K(ret), K(ls_replica));
} else {
SERVER_EVENT_ADD("storage_ha", "report_ls_meta_table",
"tenant_id", tenant_id,
"ls_id", ls_id);
LOG_INFO("report ls meta table", K(ls_replica));
}
}
DEBUG_SYNC(AFTER_MIGRATION_REPORT_LS_META_TABLE);
return ret;
}
int ObStartMigrationTask::choose_src_()
{
int ret = OB_SUCCESS;

View File

@ -234,6 +234,7 @@ private:
int deal_with_local_ls_();
int update_ls_();
int generate_tablets_migration_dag_();
int report_ls_meta_table_();
int choose_src_();
int fetch_ls_info_(const uint64_t tenant_id, const share::ObLSID &ls_id,
const common::ObAddr &member_addr, obrpc::ObCopyLSInfo &ls_info);

View File

@ -950,8 +950,31 @@ int ObLS::save_base_schema_version()
int ObLS::get_replica_status(ObReplicaStatus &replica_status)
{
int ret = OB_SUCCESS;
// Todo: need to get migration status
replica_status = REPLICA_STATUS_NORMAL;
ObMigrationStatus migration_status;
ObLSRestoreStatus restore_status;
int64_t read_lock = LSLOCKLOGMETA;
int64_t write_lock = 0;
ObLSLockGuard lock_myself(lock_, read_lock, write_lock);
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("ls is not inited", K(ret));
} else if (OB_FAIL(get_migration_status(migration_status))) {
LOG_WARN("failed to get migration status", K(ret), KPC(this));
} else if (OB_FAIL(get_restore_status(restore_status))) {
LOG_WARN("failed to get restore status", K(ret), KPC(this));
} else if (migration_status < OB_MIGRATION_STATUS_NONE
|| migration_status > OB_MIGRATION_STATUS_MAX) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("migration status is not valid", K(ret), K(migration_status));
} else if (!restore_status.is_valid()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("restore status is not valid", K(ret), K(restore_status));
} else if (OB_MIGRATION_STATUS_NONE == migration_status
&& restore_status.is_restore_none()) {
replica_status = REPLICA_STATUS_NORMAL;
} else {
replica_status = REPLICA_STATUS_OFFLINE;
}
return ret;
}