[bugfix]remove tenant_io_manager from map until mtl_destroy

This commit is contained in:
renju96
2023-07-18 05:12:19 +00:00
committed by ob-robot
parent d0582d2fdc
commit ff656e59b4
4 changed files with 21 additions and 29 deletions

View File

@ -664,7 +664,7 @@ int MockTenantModuleEnv::init()
STORAGE_LOG(ERROR, "init_before_start_mtl failed", K(ret)); STORAGE_LOG(ERROR, "init_before_start_mtl failed", K(ret));
} else { } else {
oceanbase::ObClusterVersion::get_instance().update_data_version(DATA_CURRENT_VERSION); oceanbase::ObClusterVersion::get_instance().update_data_version(DATA_CURRENT_VERSION);
MTL_BIND2(nullptr, ObTenantIOManager::mtl_init, nullptr, ObTenantIOManager::mtl_stop, ObTenantIOManager::mtl_wait, ObTenantIOManager::mtl_destroy); MTL_BIND(ObTenantIOManager::mtl_init, ObTenantIOManager::mtl_destroy);
MTL_BIND2(mtl_new_default, ObTenantSchemaService::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default); MTL_BIND2(mtl_new_default, ObTenantSchemaService::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default);
MTL_BIND2(mtl_new_default, ObStorageLogger::mtl_init, ObStorageLogger::mtl_start, ObStorageLogger::mtl_stop, ObStorageLogger::mtl_wait, mtl_destroy_default); MTL_BIND2(mtl_new_default, ObStorageLogger::mtl_init, ObStorageLogger::mtl_start, ObStorageLogger::mtl_stop, ObStorageLogger::mtl_wait, mtl_destroy_default);
MTL_BIND2(ObTenantMetaMemMgr::mtl_new, mtl_init_default, mtl_start_default, mtl_stop_default, mtl_wait_default, mtl_destroy_default); MTL_BIND2(ObTenantMetaMemMgr::mtl_new, mtl_init_default, mtl_start_default, mtl_stop_default, mtl_wait_default, mtl_destroy_default);

View File

@ -401,7 +401,7 @@ int ObMultiTenant::init(ObAddr myaddr,
} }
if (OB_SUCC(ret) && mtl_bind_flag) { if (OB_SUCC(ret) && mtl_bind_flag) {
MTL_BIND2(nullptr, ObTenantIOManager::mtl_init, nullptr, ObTenantIOManager::mtl_stop, ObTenantIOManager::mtl_wait, ObTenantIOManager::mtl_destroy); MTL_BIND(ObTenantIOManager::mtl_init, ObTenantIOManager::mtl_destroy);
// base mtl // base mtl
MTL_BIND2(mtl_new_default, storage::mds::ObTenantMdsService::mtl_init, storage::mds::ObTenantMdsService::mtl_start, storage::mds::ObTenantMdsService::mtl_stop, storage::mds::ObTenantMdsService::mtl_wait, mtl_destroy_default); MTL_BIND2(mtl_new_default, storage::mds::ObTenantMdsService::mtl_init, storage::mds::ObTenantMdsService::mtl_start, storage::mds::ObTenantMdsService::mtl_stop, storage::mds::ObTenantMdsService::mtl_wait, mtl_destroy_default);

View File

@ -611,25 +611,12 @@ int ObTenantIOManager::mtl_init(ObTenantIOManager *&io_service)
return ret; return ret;
} }
void ObTenantIOManager::mtl_stop(ObTenantIOManager *&io_service) void ObTenantIOManager::mtl_destroy(ObTenantIOManager *&io_service)
{
const uint64_t tenant_id = MTL_ID();
int ret = OB_SUCCESS;
if (OB_FAIL(OB_IO_MANAGER.remove_tenant_io_manager(tenant_id))) {
if (OB_HASH_NOT_EXIST != ret) {
LOG_WARN("remove tenant io manager failed", K(ret), K(tenant_id));
} else {
ret = OB_SUCCESS;
}
}
}
void ObTenantIOManager::mtl_wait(ObTenantIOManager *&io_service)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
while (OB_NOT_NULL(io_service) && OB_SUCC(ret)) { while (OB_NOT_NULL(io_service) && OB_SUCC(ret)) {
if (io_service->get_ref_cnt() == 0) { if (io_service->get_ref_cnt() == 1) {
break; break;
} else { } else {
if (REACH_TIME_INTERVAL(1000L * 1000L)) { //1s if (REACH_TIME_INTERVAL(1000L * 1000L)) { //1s
@ -638,18 +625,25 @@ void ObTenantIOManager::mtl_wait(ObTenantIOManager *&io_service)
ob_usleep((useconds_t)10L * 1000L); //10ms ob_usleep((useconds_t)10L * 1000L); //10ms
} }
} }
}
void ObTenantIOManager::mtl_destroy(ObTenantIOManager *&io_service) const uint64_t tenant_id = MTL_ID();
{ if (OB_FAIL(OB_IO_MANAGER.remove_tenant_io_manager(tenant_id))) {
int ret = OB_SUCCESS; if (OB_HASH_NOT_EXIST != ret) {
LOG_WARN("remove tenant io manager failed", K(ret), K(tenant_id));
} else {
ret = OB_SUCCESS;
}
}
if (OB_SUCC(ret)) {
if (OB_NOT_NULL(io_service) && io_service->get_ref_cnt() == 0) { if (OB_NOT_NULL(io_service) && io_service->get_ref_cnt() == 0) {
io_service->~ObTenantIOManager(); io_service->~ObTenantIOManager();
OB_IO_MANAGER.allocator_.free(io_service); OB_IO_MANAGER.allocator_.free(io_service);
io_service = nullptr;
} else if (OB_NOT_NULL(io_service) && io_service->get_ref_cnt() != 0) { } else if (OB_NOT_NULL(io_service) && io_service->get_ref_cnt() != 0) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("ERROR: tenant io manager ref_cnt is not zero", K(ret)); LOG_ERROR("ERROR: tenant io manager ref_cnt is not zero", K(ret));
} }
}
} }
ObTenantIOManager::ObTenantIOManager() ObTenantIOManager::ObTenantIOManager()

View File

@ -101,8 +101,6 @@ class ObTenantIOManager final
{ {
public: public:
static int mtl_init(ObTenantIOManager *&io_service); static int mtl_init(ObTenantIOManager *&io_service);
static void mtl_stop(ObTenantIOManager *&io_service);
static void mtl_wait(ObTenantIOManager *&io_service);
static void mtl_destroy(ObTenantIOManager *&io_service); static void mtl_destroy(ObTenantIOManager *&io_service);
public: public:
ObTenantIOManager(); ObTenantIOManager();