fix tmp file background gc issue, after tenant being dropped
This commit is contained in:
parent
4770dbcdcb
commit
ee48dc4c29
@ -1201,6 +1201,18 @@ int ObTmpFileManager::remove_tenant_file(const uint64_t tenant_id)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTmpFileManager::get_all_tenant_id(common::ObIArray<uint64_t> &tenant_ids)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
STORAGE_LOG(WARN, "ObTmpFileManager has not been inited", K(ret));
|
||||
} else if (OB_FAIL(OB_TMP_FILE_STORE.get_all_tenant_id(tenant_ids))) {
|
||||
STORAGE_LOG(WARN, "fail to get all tenant ids", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTmpFileManager::sync(const int64_t fd, const int64_t timeout_ms)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -352,6 +352,8 @@ public:
|
||||
int remove(const int64_t fd);
|
||||
int remove_tenant_file(const uint64_t tenant_id);
|
||||
|
||||
int get_all_tenant_id(common::ObIArray<uint64_t> &tenant_ids);
|
||||
|
||||
int sync(const int64_t fd, const int64_t timeout_ms);
|
||||
|
||||
void destroy();
|
||||
|
@ -1331,7 +1331,30 @@ int ObTmpFileStore::get_macro_block_list(ObIArray<TenantTmpBlockCntPair>& tmp_bl
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTmpFileStore::get_store(const uint64_t tenant_id, ObTmpTenantFileStore*& store)
|
||||
int ObTmpFileStore::get_all_tenant_id(common::ObIArray<uint64_t> &tenant_ids)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
STORAGE_LOG(WARN, "ObTmpFileStore has not been inited", K(ret));
|
||||
} else {
|
||||
tenant_ids.reset();
|
||||
TenantFileStoreMap::iterator iter;
|
||||
SpinRLockGuard guard(lock_);
|
||||
for (iter = tenant_file_stores_.begin(); OB_SUCC(ret) && iter != tenant_file_stores_.end();
|
||||
++iter) {
|
||||
if (OB_ISNULL(iter->second)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "fail to iterate tmp tenant file store", K(ret));
|
||||
} else if (OB_FAIL(tenant_ids.push_back(iter->first))) {
|
||||
STORAGE_LOG(WARN, "fail to push back tmp_block_cnt_pairs", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTmpFileStore::get_store(const uint64_t tenant_id, ObTmpTenantFileStore *&store)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
void* buf = NULL;
|
||||
|
@ -321,6 +321,7 @@ public:
|
||||
int free_tenant_file_store(const uint64_t tenant_id);
|
||||
int get_macro_block_list(common::ObIArray<MacroBlockId>& macro_id_list);
|
||||
int get_macro_block_list(common::ObIArray<TenantTmpBlockCntPair>& tmp_block_cnt_pairs);
|
||||
int get_all_tenant_id(common::ObIArray<uint64_t> &tenant_ids);
|
||||
|
||||
OB_INLINE int64_t get_mblk_page_nums() const
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ void ObGarbageCollector::run1()
|
||||
(void)execute_gc_except_leader_schema_drop_(gc_candidates);
|
||||
(void)execute_gc_for_leader_schema_drop_(gc_candidates);
|
||||
|
||||
(void)execute_gc_tenant_tmp_file_(gc_tenant_set);
|
||||
(void)execute_gc_tenant_tmp_file_();
|
||||
}
|
||||
usleep(gc_interval);
|
||||
seq_++;
|
||||
@ -502,18 +502,31 @@ int ObGarbageCollector::handle_pg_offline_ilog_flushed_info_map_(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObGarbageCollector::execute_gc_tenant_tmp_file_(TenantSet& gc_tenant_set)
|
||||
int ObGarbageCollector::execute_gc_tenant_tmp_file_()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
ObSEArray<uint64_t, 16> tenant_ids;
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
const int64_t begin_time = ObTimeUtility::current_time();
|
||||
|
||||
for (TenantSet::iterator it = gc_tenant_set.begin(); OB_SUCC(ret) && it != gc_tenant_set.end(); ++it) {
|
||||
const uint64_t tenant_id = it->first;
|
||||
if (OB_FAIL(FILE_MANAGER_INSTANCE_V2.remove_tenant_file(tenant_id))) {
|
||||
STORAGE_LOG(WARN, "remove tenant tmp file failed", K(ret), K(tenant_id));
|
||||
} else {
|
||||
STORAGE_LOG(INFO, "remove tenant tmp file success", K(ret), K(tenant_id));
|
||||
if (OB_FAIL(FILE_MANAGER_INSTANCE_V2.get_all_tenant_id(tenant_ids))) {
|
||||
STORAGE_LOG(WARN, "fail to get all tenant ids", K(ret));
|
||||
} else if (OB_FAIL(schema_service_->get_schema_guard(schema_guard))) {
|
||||
STORAGE_LOG(WARN, "fail to get schema guard", K(ret));
|
||||
} else if (OB_FAIL(schema_guard.check_formal_guard())) {
|
||||
STORAGE_LOG(WARN, "schema_guard is not formal", K(ret));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < tenant_ids.count(); i++) {
|
||||
const uint64_t tenant_id = tenant_ids.at(i);
|
||||
bool tenant_has_been_dropped = false;
|
||||
if (OB_FAIL(schema_guard.check_if_tenant_has_been_dropped(tenant_id, tenant_has_been_dropped))) {
|
||||
STORAGE_LOG(WARN, "fail to check if tenant hash been dropped", K(ret), K(tenant_id));
|
||||
} else if (!tenant_has_been_dropped) {
|
||||
continue;// do nothing, just skip.
|
||||
} else if (OB_FAIL(FILE_MANAGER_INSTANCE_V2.remove_tenant_file(tenant_id))) {
|
||||
STORAGE_LOG(WARN, "remove tenant tmp file failed", K(ret), K(tenant_id));
|
||||
} else {
|
||||
STORAGE_LOG(INFO, "remove tenant tmp file success", K(ret), K(tenant_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ private:
|
||||
ServerPGMap& server_pg_map, PGOfflineIlogFlushedInfoMap& pg_offline_ilog_flushed_info_map);
|
||||
int handle_pg_offline_ilog_flushed_info_map_(PGOfflineIlogFlushedInfoMap& pg_offline_ilog_flushed_info_map);
|
||||
|
||||
int execute_gc_tenant_tmp_file_(TenantSet& gc_tenant_set);
|
||||
int execute_gc_tenant_tmp_file_();
|
||||
bool check_gc_condition_() const;
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user