Fix ls which is in migration is gc with all ls replica is not exist.

This commit is contained in:
godyangfight
2024-02-07 01:18:52 +00:00
committed by ob-robot
parent 7b80c469a6
commit 64f0ff35bd
4 changed files with 46 additions and 8 deletions

View File

@ -401,16 +401,15 @@ int ObMigrationStatusHelper::check_transfer_dest_ls_status_for_ls_gc(
// and the destination can be restored through rebuilding.
int ObMigrationStatusHelper::set_ls_migrate_gc_status_(
ObLS &ls,
const ObMigrationStatus &migration_status)
bool &allow_gc)
{
int ret = OB_SUCCESS;
const ObMigrationStatus migrate_GC_status = ObMigrationStatus::OB_MIGRATION_STATUS_GC;
if (ObMigrationStatus::OB_MIGRATION_STATUS_NONE != migration_status) {
// do nothing
if (OB_FAIL(ls.set_ls_migration_gc(allow_gc))) {
LOG_WARN("failed to set migration status", K(ret));
} else if (!allow_gc) {
LOG_INFO("ls is not allow gc", K(ret), K(ls));
} else if (OB_FAIL(ls.get_log_handler()->disable_sync())) {
LOG_WARN("failed to disable replay", K(ret));
} else if (OB_FAIL(ls.set_migration_status(migrate_GC_status, ls.get_ls_meta().get_rebuild_seq()))) {
LOG_WARN("failed to set migration status", K(ret));
}
return ret;
}
@ -444,7 +443,7 @@ int ObMigrationStatusHelper::check_ls_transfer_tablet_(
} else if (FALSE_IT(ls_status = ls->get_persistent_state())) {
} else if (ls_status.is_need_gc()) {
allow_gc = true;
} else if (OB_FAIL(set_ls_migrate_gc_status_(*ls, migration_status))) {
} else if (OB_FAIL(set_ls_migrate_gc_status_(*ls, allow_gc))) {
LOG_WARN("failed to set ls gc status", KR(ret));
} else if (OB_FAIL(ls->get_restore_status(restore_status))) {
LOG_WARN("failed to get restore status", K(ret), KPC(ls));

View File

@ -117,7 +117,7 @@ private:
static bool check_migration_status_is_fail_(const ObMigrationStatus &cur_status);
static int set_ls_migrate_gc_status_(
ObLS &ls,
const ObMigrationStatus &migration_status);
bool &allow_gc);
static int check_ls_with_transfer_task_(
ObLS &ls,
bool &need_check_allow_gc,

View File

@ -2467,5 +2467,42 @@ bool ObLS::is_in_gc()
return bret;
}
int ObLS::set_ls_migration_gc(
bool &allow_gc)
{
int ret = OB_SUCCESS;
allow_gc = false;
const bool write_slog = true;
const ObMigrationStatus change_status = ObMigrationStatus::OB_MIGRATION_STATUS_GC;
ObMigrationStatus curr_status = ObMigrationStatus::OB_MIGRATION_STATUS_MAX;
ObLSRebuildInfo rebuild_info;
WRLockGuard guard(meta_rwlock_);
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
STORAGE_LOG(WARN, "ls is not inited", K(ret), K(ls_meta_));
} else if (!ls_meta_.get_persistent_state().can_update_ls_meta()) {
ret = OB_STATE_NOT_MATCH;
STORAGE_LOG(WARN, "state not match, cannot update ls meta", K(ret), K(ls_meta_));
} else if (OB_FAIL(ls_meta_.get_rebuild_info(rebuild_info))) {
LOG_WARN("failed to get rebuild info", K(ret), K(ls_meta_));
} else if (rebuild_info.is_in_rebuild()) {
allow_gc = false;
} else if (OB_FAIL(ls_meta_.get_migration_status(curr_status))) {
LOG_WARN("failed to get migration status", K(ret), K(ls_meta_));
} else if (ObMigrationStatusHelper::check_allow_gc_abandoned_ls(curr_status)) {
allow_gc = true;
} else if (ObMigrationStatus::OB_MIGRATION_STATUS_NONE != curr_status) {
allow_gc = false;
} else if (OB_FAIL(ls_meta_.set_migration_status(change_status, write_slog))) {
LOG_WARN("failed to set migration status", K(ret), K(change_status));
} else {
ls_tablet_svr_.disable_to_read();
allow_gc = true;
}
return ret;
}
}
}

View File

@ -879,6 +879,8 @@ public:
DELEGATE_WITH_RET(reserved_snapshot_mgr_, get_min_reserved_snapshot, int64_t);
DELEGATE_WITH_RET(reserved_snapshot_mgr_, add_dependent_medium_tablet, int);
DELEGATE_WITH_RET(reserved_snapshot_mgr_, del_dependent_medium_tablet, int);
int set_ls_migration_gc(bool &allow_gc);
private:
// StorageBaseUtil
// table manager: create, remove and guard get.