[CP] [RS][Bugfix] Fix bug blocking deleting offline server.

This commit is contained in:
obdev
2023-08-30 04:44:13 +00:00
committed by ob-robot
parent e3abf683f4
commit b84f0f309c
2 changed files with 37 additions and 3 deletions

View File

@ -122,7 +122,9 @@ int ObEmptyServerChecker::try_delete_server_()
const ObAddr &addr= server_info->get_server();
if (OB_FAIL(unit_mgr_->check_server_empty(addr, server_empty))) {
LOG_WARN("check_server_empty failed", "server", addr, KR(ret));
} else if (server_empty && OB_FAIL(empty_servers_.push_back(addr))) {
} else if (!server_empty) {
LOG_INFO("server not empty and has units on it", "server", addr, KR(ret));
} else if (OB_FAIL(empty_servers_.push_back(addr))) {
LOG_WARN("failed to push back empty server", KR(ret), KPC(server_info));
}
}

View File

@ -59,16 +59,20 @@ int ObUnitStatManager::gather_stat()
{
int ret = OB_SUCCESS;
ObArray<share::ObUnitStat> unit_stats;
ObArray<share::ObUnit> units;
unit_stat_map_.reuse();
if (!inited_) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else if (OB_FAIL(ut_operator_.get_unit_stats(unit_stats))) {
LOG_WARN("get unit_stats failed", KR(ret));
} else if (OB_FAIL(ut_operator_.get_units(units))) {
LOG_WARN("get units failed", KR(ret));
} else {
ObUnitStatMap::Item *item;
ObUnitStatMap::Item *item = NULL;
FOREACH_CNT_X(unit_stat, unit_stats, OB_SUCC(ret)) {
if (OB_FAIL(unit_stat_map_.locate(unit_stat->get_unit_id(), item))) {
LOG_WARN("fail to init stat for unit", KR(ret), K(unit_stat->get_unit_id()));
LOG_WARN("fail to locate unit_stat", KR(ret), K(unit_stat->get_unit_id()));
} else if (OB_FAIL(ERRSIM_UNIT_DISK_ASSIGN)) {
if (OB_FAIL(item->v_.init(unit_stat->get_unit_id(),
1024 * 1024 * 1024, // assign 1 GB for test use only
@ -82,6 +86,34 @@ int ObUnitStatManager::gather_stat()
item->v_.deep_copy(*unit_stat);
}
}
// FIXME: (cangming.zl) temp workaround for problem of units on offline servers.
FOREACH_CNT_X(unit, units, OB_SUCC(ret)) {
share::ObUnitStat tmp_unit_stat;
if (OB_SUCC(unit_stat_map_.get(unit->unit_id_, tmp_unit_stat))) {
// do nothing, unit_stat of this unit is already set
} else {
if (OB_HASH_NOT_EXIST != ret) {
LOG_WARN("fail to try to get from unit_stat_map", KR(ret), K(unit->unit_id_));
} else { /*OB_HASH_NOT_EXIST*/
// Let required_size of unit_stat unable to get from __all_virtual_unit be 0
ret = OB_SUCCESS;
if (OB_FAIL(unit_stat_map_.locate(unit->unit_id_, item))) {
LOG_WARN("fail to locate unit_stat", KR(ret), K(unit->unit_id_));
} else {
if (OB_ISNULL(item)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("item is nullptr", KR(ret));
} else if (OB_FAIL(item->v_.init(unit->unit_id_,
0 /*required_size*/,
unit->migrate_from_server_.is_valid()/*is_migrating*/))) {
LOG_WARN("fail to init unit_stat", KR(ret), K(unit->unit_id_));
} else {
LOG_INFO("unit not in unit_stat_map, set required_size as 0", KR(ret), K(unit->unit_id_));
}
}
}
}
}
}
if (OB_SUCC(ret)) {
loaded_stats_ = true;