From 7c84616bc4f29768049f5aecdea3d025077ba527 Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Thu, 3 Mar 2022 22:32:39 +0800 Subject: [PATCH] fix hangs on authenticate --- Cargo.lock | 2 +- query/Cargo.toml | 2 +- .../servers/mysql/mysql_interactive_worker.rs | 31 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d8663d9a5b9..d0eee6400010 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4102,7 +4102,7 @@ dependencies = [ [[package]] name = "msql-srv" version = "0.9.6" -source = "git+https://github.com/datafuse-extras/msql-srv?rev=70aa0b2#70aa0b2a7a2096be67a2da5961f10dbe4f7f1d95" +source = "git+https://github.com/datafuse-extras/msql-srv?rev=af29f7b#af29f7b4a3bb7d738b91afa7a00c9dd5673f0c0a" dependencies = [ "async-trait", "byteorder", diff --git a/query/Cargo.toml b/query/Cargo.toml index 28178260a17b..4b4346ec2c2e 100644 --- a/query/Cargo.toml +++ b/query/Cargo.toml @@ -53,7 +53,7 @@ common-tracing = { path = "../common/tracing" } # Github dependencies cargo-license = { git = "https://github.com/datafuse-extras/cargo-license", rev = "f1ce4a2" } -msql-srv = { git = "https://github.com/datafuse-extras/msql-srv", rev = "70aa0b2" } +msql-srv = { git = "https://github.com/datafuse-extras/msql-srv", rev = "af29f7b" } sqlparser = { git = "https://github.com/datafuse-extras/sqlparser-rs", rev = "472f5b6" } # Crates.io dependencies diff --git a/query/src/servers/mysql/mysql_interactive_worker.rs b/query/src/servers/mysql/mysql_interactive_worker.rs index eb64c212159e..749bc4e0cabf 100644 --- a/query/src/servers/mysql/mysql_interactive_worker.rs +++ b/query/src/servers/mysql/mysql_interactive_worker.rs @@ -55,7 +55,7 @@ pub struct InteractiveWorker { } #[async_trait::async_trait] -impl AsyncMysqlShim for InteractiveWorker { +impl AsyncMysqlShim for InteractiveWorker { type Error = ErrorCode; fn version(&self) -> &str { @@ -78,7 +78,7 @@ impl AsyncMysqlShim for InteractiveWorker { self.salt } - fn authenticate( + async fn authenticate( &self, _auth_plugin: &str, username: &[u8], @@ -86,26 +86,25 @@ impl AsyncMysqlShim for InteractiveWorker { auth_data: &[u8], ) -> bool { let username = String::from_utf8_lossy(username); - let info = CertifiedInfo::create(&username, auth_data, &self.client_addr); + let client_addr = self.client_addr.clone(); + let info = CertifiedInfo::create(&username, auth_data, &client_addr); let authenticate = self.base.authenticate(salt, info); - futures::executor::block_on(async move { - match authenticate.await { - Ok(res) => res, - Err(failure) => { - tracing::error!( - "MySQL handler authenticate failed, \ + match authenticate.await { + Ok(res) => res, + Err(failure) => { + tracing::error!( + "MySQL handler authenticate failed, \ user_name: {}, \ client_address: {}, \ failure_cause: {}", - username, - self.client_addr, - failure - ); - false - } + username, + client_addr, + failure + ); + false } - }) + } } async fn on_prepare<'a>(