From 2139a162830ecaacb18056018216df2bb7702c00 Mon Sep 17 00:00:00 2001 From: taichong Date: Thu, 19 May 2022 14:19:07 +0800 Subject: [PATCH] modify code --- query/src/sessions/session_mgr.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/query/src/sessions/session_mgr.rs b/query/src/sessions/session_mgr.rs index 3fc3404d99528..925718a23dcd1 100644 --- a/query/src/sessions/session_mgr.rs +++ b/query/src/sessions/session_mgr.rs @@ -158,22 +158,16 @@ impl SessionManager { )); } } + let id = uuid::Uuid::new_v4().to_string(); let session_typ = typ.clone(); - let session = Session::try_create( - config.clone(), - uuid::Uuid::new_v4().to_string(), - typ, - self.clone(), - ) - .await?; - match session_typ { SessionType::MySQL => { let mut conn_id_session_id = self.mysql_conn_map.write(); if conn_id_session_id.len() < self.max_sessions { - conn_id_session_id.insert(session.get_mysql_conn_id(), session.get_id()); - self.mysql_basic_conn_id.fetch_add(1, Ordering::Relaxed); - self.mysql_basic_conn_id.load(Ordering::Relaxed); + conn_id_session_id.insert( + Some(self.mysql_basic_conn_id.fetch_add(1, Ordering::Relaxed)), + id.clone(), + ); } else { return Err(ErrorCode::TooManyUserConnections( "The current accept connection has exceeded max_active_sessions config", @@ -187,6 +181,7 @@ impl SessionManager { ); } } + let session = Session::try_create(config.clone(), id, typ, self.clone()).await?; let mut sessions = self.active_sessions.write(); if sessions.len() < self.max_sessions {