提交 36af412e 编写于 作者: T Tyshawn 提交者: LINGuanRen

[BUGFIX] fix sstable double free both gc by iter and gc by queue.

上级 18de895d
......@@ -103,6 +103,19 @@ int ObPGSSTableGarbageCollector::gc_free_sstable_by_pg_iter()
left_recycle_cnt -= recycle_cnt;
}
}
if (OB_SUCC(ret)) {
while (OB_SUCC(ret) && free_sstables_queue_.size() > 0) {
ObLink *ptr = NULL;
if (OB_FAIL(free_sstables_queue_.pop(ptr))) {
LOG_WARN("fail to pop item", K(ret));
} else if (OB_ISNULL(ptr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected error, ptr is nullptr", K(ret), KP(ptr));
} else {
free_sstable_gc_item(static_cast<ObSSTableGCItem *>(ptr));
}
}
}
}
if (nullptr != partition_iter) {
ObPartitionService::get_instance().revert_pg_iter(partition_iter);
......
......@@ -3203,15 +3203,19 @@ int ObSSTable::add_macro_ref()
int64_t ObSSTable::dec_ref()
{
int64_t ref_cnt = ATOMIC_SAF(&ref_cnt_, 1 /* just sub 1 */);
if (0 == ref_cnt) {
// If current ref_cnt is 1, it should be pushed into gc queue firstly. Then, decrease reference
// counts. The reason is that gc by iter may be faster than gc by queue.
if (1 == get_ref()) {
int ret = OB_SUCCESS;
if (OB_FAIL(ObPGSSTableGarbageCollector::get_instance().push_sstable_into_gc_queue(key_))) {
LOG_WARN("fail to push sstable into gc queue", K(ret), K(key_));
}
}
int64_t ref_cnt = ATOMIC_SAF(&ref_cnt_, 1 /* just sub 1 */);
if (OB_UNLIKELY(ref_cnt < 0)) {
LOG_ERROR("Unexpected ref cnt of sstable", K(ref_cnt), K(key_));
}
return ref_cnt;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册