Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hangs on authenticate #4317

Merged
merged 2 commits into from Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion query/Cargo.toml
Expand Up @@ -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
Expand Down
31 changes: 15 additions & 16 deletions query/src/servers/mysql/mysql_interactive_worker.rs
Expand Up @@ -55,7 +55,7 @@ pub struct InteractiveWorker<W: std::io::Write> {
}

#[async_trait::async_trait]
impl<W: std::io::Write + Send> AsyncMysqlShim<W> for InteractiveWorker<W> {
impl<W: std::io::Write + Send + Sync> AsyncMysqlShim<W> for InteractiveWorker<W> {
type Error = ErrorCode;

fn version(&self) -> &str {
Expand All @@ -78,34 +78,33 @@ impl<W: std::io::Write + Send> AsyncMysqlShim<W> for InteractiveWorker<W> {
self.salt
}

fn authenticate(
async fn authenticate(
&self,
_auth_plugin: &str,
username: &[u8],
salt: &[u8],
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>(
Expand Down