diff --git a/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp b/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp index e1266af6f0..f5dd741263 100644 --- a/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp +++ b/deps/oblib/src/rpc/obmysql/ob_sql_nio.cpp @@ -654,6 +654,20 @@ public: tcp_keepintvl_ = tcp_keepintvl; tcp_keepcnt_ = tcp_keepcnt; } + void close_all_fd() { + if (lfd_ > 0) { + IGNORE_RETURN epoll_ctl(epfd_, EPOLL_CTL_DEL, lfd_, NULL); + close(lfd_); + lfd_ = -1; + } + ObDLink* head = all_list_.head(); + ObLink* cur = head->next_; + while (cur != head) { + ObSqlSock* s = CONTAINER_OF(cur, ObSqlSock, all_list_link_); + cur = cur->next_; + s->do_close(); + } + } private: void handle_epoll_event() { const int maxevents = 512; @@ -937,6 +951,9 @@ void ObSqlNio::run(int64_t idx) while(!has_set_stop()) { impl_[idx].do_work(); } + if (has_set_stop()) { + impl_[idx].close_all_fd(); + } } } diff --git a/mittest/mtlenv/mock_tenant_module_env.h b/mittest/mtlenv/mock_tenant_module_env.h index cb4424d56a..821b2ce996 100644 --- a/mittest/mtlenv/mock_tenant_module_env.h +++ b/mittest/mtlenv/mock_tenant_module_env.h @@ -737,6 +737,7 @@ void MockTenantModuleEnv::destroy() ObTsMgr::get_instance().wait(); ObTsMgr::get_instance().destroy(); + net_frame_.sql_nio_stop(); net_frame_.stop(); net_frame_.wait(); net_frame_.destroy(); diff --git a/src/observer/ob_server.cpp b/src/observer/ob_server.cpp index 70e76c999f..5dc25442f1 100644 --- a/src/observer/ob_server.cpp +++ b/src/observer/ob_server.cpp @@ -898,6 +898,10 @@ int ObServer::stop() FLOG_INFO("mysql shutdown network stopped"); } + FLOG_INFO("begin to sql nio stop"); + net_frame_.sql_nio_stop(); + FLOG_INFO("sql nio stopped"); + FLOG_INFO("begin to stop active session history task"); ObActiveSessHistTask::get_instance().stop(); FLOG_INFO("active session history task stopped"); diff --git a/src/observer/ob_srv_network_frame.cpp b/src/observer/ob_srv_network_frame.cpp index 11cf83abf3..29c517c49b 100644 --- a/src/observer/ob_srv_network_frame.cpp +++ b/src/observer/ob_srv_network_frame.cpp @@ -453,9 +453,6 @@ int ObSrvNetworkFrame::stop() if (OB_FAIL(net_.stop())) { LOG_WARN("stop easy net fail", K(ret)); } - if (NULL != obmysql::global_sql_nio_server) { - obmysql::global_sql_nio_server->stop(); - } return ret; } @@ -489,3 +486,10 @@ void ObSrvNetworkFrame::set_ratelimit_enable(int ratelimit_enabled) rpc_transport_->set_ratelimit_enable(ratelimit_enabled); batch_rpc_transport_->set_ratelimit_enable(ratelimit_enabled); } + +void ObSrvNetworkFrame::sql_nio_stop() +{ + if (NULL != obmysql::global_sql_nio_server) { + obmysql::global_sql_nio_server->stop(); + } +} \ No newline at end of file diff --git a/src/observer/ob_srv_network_frame.h b/src/observer/ob_srv_network_frame.h index cb8f36dc1e..025eb0d66f 100644 --- a/src/observer/ob_srv_network_frame.h +++ b/src/observer/ob_srv_network_frame.h @@ -49,6 +49,7 @@ public: int high_prio_rpc_shutdown(); int batch_rpc_shutdown(); int unix_rpc_shutdown(); + void sql_nio_stop(); void wait(); int stop(); diff --git a/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp b/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp index 15d520f9f1..ee33de0102 100644 --- a/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp +++ b/src/storage/memtable/mvcc/ob_mvcc_trans_ctx.cpp @@ -1204,6 +1204,8 @@ int ObMvccRowCallback::log_sync_fail() { int ret = OB_SUCCESS; + ObRowLatchGuard guard(value_.latch_); + if (OB_FAIL(dec_unsynced_cnt_())) { TRANS_LOG(ERROR, "memtable dec unsynced cnt error", K(ret), K(memtable_->get_unsynced_cnt())); diff --git a/unittest/storage/mockcontainer/mock_ob_server.cpp b/unittest/storage/mockcontainer/mock_ob_server.cpp index 43b9a7690d..01318307ce 100644 --- a/unittest/storage/mockcontainer/mock_ob_server.cpp +++ b/unittest/storage/mockcontainer/mock_ob_server.cpp @@ -334,6 +334,7 @@ int MockObServer::stop() if (!is_inited_) { STORAGE_LOG(WARN, "ob server not inited"); ret = OB_NOT_INIT; + } else if (FALSE_IT(net_frame_.sql_nio_stop())) { } else if (OB_SUCCESS != (ret = net_frame_.stop())) { STORAGE_LOG(WARN, "net frame stop error", K(ret)); } else {