File tree Expand file tree Collapse file tree 4 files changed +7
-20
lines changed Expand file tree Collapse file tree 4 files changed +7
-20
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ impl SingletonType {
56
56
let guard = LOCAL . wait ( ) . read ( ) ;
57
57
let v: & T = guard
58
58
. get ( & thread_name)
59
- . unwrap_or_else ( || panic ! ( "thread {thread_name} is not initiated" ) )
59
+ . unwrap_or_else ( || panic ! ( "thread {thread_name} is not initiated, don't worry if we are in dropping " ) )
60
60
. get ( ) ;
61
61
v. clone ( )
62
62
}
@@ -75,7 +75,7 @@ impl SingletonType {
75
75
let guard = LOCAL . wait ( ) . read ( ) ;
76
76
guard
77
77
. get ( & thread_name)
78
- . unwrap_or_else ( || panic ! ( "thread {thread_name} is not initiated" ) )
78
+ . unwrap_or_else ( || panic ! ( "thread {thread_name} is not initiated, don't worry if we are in dropping " ) )
79
79
. set ( value)
80
80
}
81
81
}
Original file line number Diff line number Diff line change @@ -158,8 +158,10 @@ impl SessionManager {
158
158
159
159
// stop tracking session
160
160
{
161
- let mut sessions = self . active_sessions . write ( ) ;
162
- sessions. remove ( session_id) ;
161
+ // Make sure this write lock has been released before dropping.
162
+ // Becuase droping session could re-enter `destroy_session`.
163
+ let weak_session = { self . active_sessions . write ( ) . remove ( session_id) } ;
164
+ drop ( weak_session) ;
163
165
}
164
166
165
167
// also need remove mysql_conn_map
Original file line number Diff line number Diff line change @@ -1383,7 +1383,7 @@ async fn test_func_object_keys() -> Result<()> {
1383
1383
Ok ( ( ) )
1384
1384
}
1385
1385
1386
- #[ tokio:: test( flavor = "current_thread" ) ]
1386
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1387
1387
async fn test_multi_partition ( ) -> Result < ( ) > {
1388
1388
let _guard = TestGlobalServices :: setup ( ConfigBuilder :: create ( ) . build ( ) ) . await ?;
1389
1389
Original file line number Diff line number Diff line change @@ -17,9 +17,7 @@ use common_config::Config;
17
17
use common_exception:: Result ;
18
18
use common_tracing:: set_panic_hook;
19
19
use databend_query:: clusters:: ClusterDiscovery ;
20
- use databend_query:: sessions:: SessionManager ;
21
20
use databend_query:: GlobalServices ;
22
- use tracing:: debug;
23
21
use tracing:: info;
24
22
25
23
pub struct TestGlobalServices ;
@@ -64,19 +62,6 @@ pub struct TestGuard {
64
62
65
63
impl Drop for TestGuard {
66
64
fn drop ( & mut self ) {
67
- // Check if session manager sill have active sessions.
68
- {
69
- let session_mgr = SessionManager :: instance ( ) ;
70
- // Destory all sessions.
71
- for process in session_mgr. processes_info ( ) {
72
- session_mgr. destroy_session ( & process. id ) ;
73
- }
74
- // Double check again.
75
- for process in session_mgr. processes_info ( ) {
76
- debug ! ( "process {process:?} still running after drop, something must be wrong" ) ;
77
- }
78
- }
79
-
80
65
GlobalInstance :: drop_testing ( & self . thread_name ) ;
81
66
}
82
67
}
You can’t perform that action at this time.
0 commit comments