Skip to content

Commit a04f8e1

Browse files
committed
Make sure all sessions have been destoried
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent c34d32f commit a04f8e1

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

src/query/catalog/src/table_context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::plan::PartInfoPtr;
3636
use crate::plan::Partitions;
3737
use crate::table::Table;
3838

39+
#[derive(Debug)]
3940
pub struct ProcessInfo {
4041
pub id: String,
4142
pub typ: String,

src/query/service/tests/it/servers/http/http_query_handlers.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ async fn post_json_to_endpoint(
768768
check_response(response).await
769769
}
770770

771-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
771+
#[tokio::test(flavor = "current_thread")]
772772
async fn test_auth_jwt() -> Result<()> {
773773
let user_name = "root";
774774

@@ -897,7 +897,7 @@ async fn assert_auth_current_role(
897897
Ok(())
898898
}
899899

900-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
900+
#[tokio::test(flavor = "current_thread")]
901901
async fn test_auth_jwt_with_create_user() -> Result<()> {
902902
let user_name = "user1";
903903

@@ -1002,7 +1002,7 @@ async fn test_http_handler_tls_server() -> Result<()> {
10021002
Ok(())
10031003
}
10041004

1005-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1005+
#[tokio::test(flavor = "current_thread")]
10061006
async fn test_http_handler_tls_server_failed_case_1() -> Result<()> {
10071007
let config = ConfigBuilder::create()
10081008
.http_handler_tls_server_key(TEST_SERVER_KEY)
@@ -1074,7 +1074,7 @@ async fn test_http_service_tls_server_mutual_tls() -> Result<()> {
10741074
}
10751075

10761076
// cannot connect with server unless it have CA signed identity
1077-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1077+
#[tokio::test(flavor = "current_thread")]
10781078
async fn test_http_service_tls_server_mutual_tls_failed() -> Result<()> {
10791079
let _guard = TestGlobalServices::setup(
10801080
ConfigBuilder::create()
@@ -1470,7 +1470,7 @@ async fn test_affect() -> Result<()> {
14701470
Ok(())
14711471
}
14721472

1473-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1473+
#[tokio::test(flavor = "current_thread")]
14741474
async fn test_auth_configured_user() -> Result<()> {
14751475
let user_name = "conf_user";
14761476
let pass_word = "conf_user_pwd";

src/query/service/tests/it/tests/sessions.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::time::Duration;
16-
1715
use common_base::base::GlobalInstance;
1816
use common_config::Config;
1917
use common_exception::Result;
2018
use common_tracing::set_panic_hook;
2119
use databend_query::clusters::ClusterDiscovery;
2220
use databend_query::sessions::SessionManager;
2321
use databend_query::GlobalServices;
24-
use time::Instant;
22+
use tracing::debug;
2523
use tracing::info;
2624

2725
pub struct TestGlobalServices;
@@ -63,13 +61,16 @@ pub struct TestGuard {
6361

6462
impl Drop for TestGuard {
6563
fn drop(&mut self) {
66-
// Hack: The session may be referenced by other threads. Let's try to wait.
67-
let now = Instant::now();
68-
while !SessionManager::instance().processes_info().is_empty() {
69-
std::thread::sleep(Duration::from_millis(500));
70-
71-
if now.elapsed() > Duration::from_secs(3) {
72-
break;
64+
// Check if session manager sill have active sessions.
65+
{
66+
let session_mgr = SessionManager::instance();
67+
// Destory all sessions.
68+
for process in session_mgr.processes_info() {
69+
session_mgr.destroy_session(&process.id);
70+
}
71+
// Double check again.
72+
for process in session_mgr.processes_info() {
73+
debug!("process {process:?} still running after drop, something must be wrong");
7374
}
7475
}
7576

src/query/settings/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct SettingValue {
6363
possible_values: Option<Vec<&'static str>>,
6464
}
6565

66-
#[derive(Clone)]
66+
#[derive(Clone, Debug)]
6767
pub struct Settings {
6868
settings: Arc<DashMap<String, SettingValue>>,
6969
// TODO verify this, will tenant change during the lifetime of a given session?

0 commit comments

Comments
 (0)