[CP] free a dup_tablet_set after 4013
This commit is contained in:
@ -384,18 +384,8 @@ int ObLSDupTabletsMgr::init_free_tablet_pool_()
|
|||||||
const uint64_t tenant_id = MTL_ID();
|
const uint64_t tenant_id = MTL_ID();
|
||||||
|
|
||||||
for (int i = 0; i < RESERVED_FREE_SET_COUNT && OB_SUCC(ret); i++) {
|
for (int i = 0; i < RESERVED_FREE_SET_COUNT && OB_SUCC(ret); i++) {
|
||||||
DupTabletChangeMap *tmp_map_ptr = nullptr;
|
if (OB_FAIL(alloc_one_free_tablet_set_(i + 1))) {
|
||||||
if (OB_ISNULL(tmp_map_ptr = static_cast<DupTabletChangeMap *>(
|
DUP_TABLE_LOG(WARN, "alloc one free tablet set failed", K(ret), K(i));
|
||||||
share::mtl_malloc(sizeof(DupTabletChangeMap), "DupTabletMap")))) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
// } else if (OB_FALSE_IT(extra_free_set_alloc_count_++)) {
|
|
||||||
} else if (OB_FALSE_IT(new (tmp_map_ptr) DupTabletChangeMap(i + 1))) {
|
|
||||||
} else if (OB_FAIL(tmp_map_ptr->create(tenant_id, 1024))) {
|
|
||||||
DUP_TABLE_LOG(WARN, "create dup_tablet hash map", K(ret));
|
|
||||||
} else if (false == (free_set_pool_.add_last(tmp_map_ptr))) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
DUP_TABLE_LOG(WARN, "push back into free_set_pool failed", K(ret),
|
|
||||||
K(free_set_pool_.get_size()), KPC(tmp_map_ptr));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2318,29 +2308,58 @@ int ObLSDupTabletsMgr::discover_dup_tablet_(const common::ObTabletID &tablet_id,
|
|||||||
K(readable_tablets_list_.get_size()));
|
K(readable_tablets_list_.get_size()));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
int ObLSDupTabletsMgr::alloc_extra_free_tablet_set_()
|
|
||||||
|
int ObLSDupTabletsMgr::alloc_one_free_tablet_set_(const uint64_t uid)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|
||||||
|
const int64_t origin_free_set_size = free_set_pool_.get_size();
|
||||||
|
bool construct_object_succ = true;
|
||||||
|
|
||||||
DupTabletChangeMap *tmp_map_ptr = nullptr;
|
DupTabletChangeMap *tmp_map_ptr = nullptr;
|
||||||
const uint64_t tenant_id = MTL_ID();
|
const uint64_t tenant_id = MTL_ID();
|
||||||
|
|
||||||
if (OB_ISNULL(tmp_map_ptr = static_cast<DupTabletChangeMap *>(
|
if (OB_ISNULL(tmp_map_ptr = static_cast<DupTabletChangeMap *>(
|
||||||
share::mtl_malloc(sizeof(DupTabletChangeMap), "DupTabletMap")))) {
|
share::mtl_malloc(sizeof(DupTabletChangeMap), "DupTabletMap")))) {
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
} else if (OB_FALSE_IT(extra_free_set_alloc_count_++)) {
|
DUP_TABLE_LOG(WARN, "alloc a dup tablet map failed", K(ret), K(uid), KPC(tmp_map_ptr));
|
||||||
} else if (OB_FALSE_IT(new (tmp_map_ptr) DupTabletChangeMap(RESERVED_FREE_SET_COUNT
|
} else if (OB_FALSE_IT(new (tmp_map_ptr) DupTabletChangeMap(uid))) {
|
||||||
+ extra_free_set_alloc_count_))) {
|
} else if (OB_FALSE_IT(construct_object_succ = true)) {
|
||||||
} else if (OB_FAIL(tmp_map_ptr->create(tenant_id, 1024))) {
|
} else if (OB_FAIL(tmp_map_ptr->create(tenant_id, 1024))) {
|
||||||
DUP_TABLE_LOG(WARN, "create dup_tablet hash map", K(ret));
|
DUP_TABLE_LOG(WARN, "create dup_tablet hash map", K(ret));
|
||||||
} else if (false == (free_set_pool_.add_last(tmp_map_ptr))) {
|
} else if (false == (free_set_pool_.add_last(tmp_map_ptr))) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
DUP_TABLE_LOG(WARN, "push back into free_set_pool failed", K(ret), K(free_set_pool_.get_size()),
|
DUP_TABLE_LOG(WARN, "push back into free_set_pool failed", K(ret), K(free_set_pool_.get_size()),
|
||||||
KPC(tmp_map_ptr));
|
KPC(tmp_map_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
if (free_set_pool_.get_size() == origin_free_set_size) {
|
||||||
|
if (OB_NOT_NULL(tmp_map_ptr)) {
|
||||||
|
if (construct_object_succ) {
|
||||||
|
if (tmp_map_ptr->created()) {
|
||||||
|
tmp_map_ptr->destroy();
|
||||||
|
}
|
||||||
|
tmp_map_ptr->~DupTabletChangeMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
mtl_free(tmp_map_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DUP_TABLE_LOG(
|
||||||
|
ERROR, "unexpected free set in hash_map, rewrite the err_code as OB_ERR_UNEXPECTED",
|
||||||
|
K(ret), KPC(tmp_map_ptr), K(origin_free_set_size), K(free_set_pool_.get_size()));
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (uid > RESERVED_FREE_SET_COUNT) {
|
||||||
DUP_TABLE_LOG(INFO, "alloc a extra free tablet set", K(ret), K(last_no_free_set_time_),
|
DUP_TABLE_LOG(INFO, "alloc a extra free tablet set", K(ret), K(last_no_free_set_time_),
|
||||||
K(extra_free_set_alloc_count_), KPC(changing_new_set_),
|
K(uid), K(extra_free_set_alloc_count_), KPC(changing_new_set_),
|
||||||
K(free_set_pool_.get_size()), K(need_confirm_new_queue_.get_size()),
|
K(free_set_pool_.get_size()), K(need_confirm_new_queue_.get_size()),
|
||||||
K(readable_tablets_list_.get_size()));
|
K(readable_tablets_list_.get_size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2365,8 +2384,11 @@ int ObLSDupTabletsMgr::get_free_tablet_set(DupTabletChangeMap *&free_set,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (OB_SUCC(ret) && target_id > RESERVED_FREE_SET_COUNT + extra_free_set_alloc_count_) {
|
while (OB_SUCC(ret) && target_id > RESERVED_FREE_SET_COUNT + extra_free_set_alloc_count_) {
|
||||||
if (OB_FAIL(alloc_extra_free_tablet_set_())) {
|
if (OB_FAIL(
|
||||||
|
alloc_one_free_tablet_set_(RESERVED_FREE_SET_COUNT + extra_free_set_alloc_count_ + 1))) {
|
||||||
DUP_TABLE_LOG(WARN, "alloc extra free tablet set failed", K(ret));
|
DUP_TABLE_LOG(WARN, "alloc extra free tablet set failed", K(ret));
|
||||||
|
} else {
|
||||||
|
extra_free_set_alloc_count_++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2377,8 +2399,12 @@ int ObLSDupTabletsMgr::get_free_tablet_set(DupTabletChangeMap *&free_set,
|
|||||||
|
|
||||||
if (force_alloc || extra_free_set_alloc_count_ < MAX_FREE_SET_COUNT - RESERVED_FREE_SET_COUNT
|
if (force_alloc || extra_free_set_alloc_count_ < MAX_FREE_SET_COUNT - RESERVED_FREE_SET_COUNT
|
||||||
|| ObTimeUtility::fast_current_time() - last_no_free_set_time_ >= 3 * 1000 * 1000) {
|
|| ObTimeUtility::fast_current_time() - last_no_free_set_time_ >= 3 * 1000 * 1000) {
|
||||||
if (OB_FAIL(alloc_extra_free_tablet_set_())) {
|
if (OB_FAIL(alloc_one_free_tablet_set_(RESERVED_FREE_SET_COUNT + extra_free_set_alloc_count_
|
||||||
DUP_TABLE_LOG(WARN, "alloc extra free tablet set failed", K(ret));
|
+ 1))) {
|
||||||
|
DUP_TABLE_LOG(WARN, "alloc extra free tablet set failed", K(ret),
|
||||||
|
K(RESERVED_FREE_SET_COUNT), K(extra_free_set_alloc_count_));
|
||||||
|
} else {
|
||||||
|
extra_free_set_alloc_count_++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -807,9 +807,8 @@ private:
|
|||||||
int init_free_tablet_pool_();
|
int init_free_tablet_pool_();
|
||||||
int destroy_free_tablet_pool_();
|
int destroy_free_tablet_pool_();
|
||||||
|
|
||||||
// int get_changing_new_set_(DupTabletChangeMap *&changing_new_set);
|
int alloc_one_free_tablet_set_(const uint64_t uid);
|
||||||
// int get_old_tablet_set_(DupTabletChangeMap *&old_tablet_set);
|
|
||||||
int alloc_extra_free_tablet_set_();
|
|
||||||
int get_free_tablet_set(DupTabletChangeMap *&free_set,
|
int get_free_tablet_set(DupTabletChangeMap *&free_set,
|
||||||
const bool force_alloc = false,
|
const bool force_alloc = false,
|
||||||
const uint64_t target_id = 0);
|
const uint64_t target_id = 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user