fix erase when iterate map
This commit is contained in:
@ -92,7 +92,15 @@ int ObScheduleSuspectInfoMgr::init()
|
|||||||
|
|
||||||
void ObScheduleSuspectInfoMgr::destroy()
|
void ObScheduleSuspectInfoMgr::destroy()
|
||||||
{
|
{
|
||||||
|
common::SpinWLockGuard guard(lock_);
|
||||||
if (info_map_.created()) {
|
if (info_map_.created()) {
|
||||||
|
auto free_map_entry = [this](common::hash::HashMapPair<int64_t, ObScheduleSuspectInfo *> &entry) {
|
||||||
|
ObScheduleSuspectInfo *info = entry.second;
|
||||||
|
info->~ObScheduleSuspectInfo();
|
||||||
|
allocator_.free((void *)info);
|
||||||
|
return OB_SUCCESS;
|
||||||
|
};
|
||||||
|
info_map_.foreach_refactored(free_map_entry);
|
||||||
info_map_.destroy();
|
info_map_.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,13 +197,22 @@ int ObScheduleSuspectInfoMgr::gc_info()
|
|||||||
int tmp_ret = OB_SUCCESS;
|
int tmp_ret = OB_SUCCESS;
|
||||||
int64_t gc_cnt = 0;
|
int64_t gc_cnt = 0;
|
||||||
ObScheduleSuspectInfo *info = nullptr;
|
ObScheduleSuspectInfo *info = nullptr;
|
||||||
|
ObSEArray<int64_t, 128> remove_info_keys;
|
||||||
const int64_t gc_time = ObTimeUtility::fast_current_time() - GC_INFO_TIME_LIMIT;
|
const int64_t gc_time = ObTimeUtility::fast_current_time() - GC_INFO_TIME_LIMIT;
|
||||||
common::SpinWLockGuard guard(lock_);
|
common::SpinWLockGuard guard(lock_);
|
||||||
for (InfoMap::iterator iter = info_map_.begin(); iter != info_map_.end(); ++iter) {
|
for (InfoMap::iterator iter = info_map_.begin(); iter != info_map_.end(); ++iter) {
|
||||||
if (OB_NOT_NULL(info = iter->second)) {
|
if (OB_NOT_NULL(info = iter->second)) {
|
||||||
if (info->add_time_ < gc_time) {
|
if (info->add_time_ < gc_time && OB_TMP_FAIL(remove_info_keys.push_back(iter->first))) {
|
||||||
if (OB_TMP_FAIL(info_map_.erase_refactored(iter->first))) {
|
LOG_WARN("failed to push back remove info key", K(tmp_ret), K(iter->first));
|
||||||
LOG_WARN("failed to erase from map", K(tmp_ret), K(iter->first));
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int64_t i = 0; i < remove_info_keys.count(); ++i) {
|
||||||
|
if (OB_TMP_FAIL(info_map_.get_refactored(remove_info_keys.at(i), info))) {
|
||||||
|
LOG_WARN("failed to get from map", K(tmp_ret), K(remove_info_keys.at(i)));
|
||||||
|
} else if (OB_NOT_NULL(info)) {
|
||||||
|
if (OB_TMP_FAIL(info_map_.erase_refactored(remove_info_keys.at(i)))) {
|
||||||
|
LOG_WARN("failed to erase from map", K(tmp_ret), K(remove_info_keys.at(i)));
|
||||||
} else {
|
} else {
|
||||||
gc_cnt++;
|
gc_cnt++;
|
||||||
allocator_.free(info);
|
allocator_.free(info);
|
||||||
@ -203,7 +220,6 @@ int ObScheduleSuspectInfoMgr::gc_info()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
STORAGE_LOG(INFO, "gc schedule suspect info", K(gc_time), K(gc_cnt), "rest_cnt", info_map_.size());
|
STORAGE_LOG(INFO, "gc schedule suspect info", K(gc_time), K(gc_cnt), "rest_cnt", info_map_.size());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user