Skip to content

Commit 4e3dfb9

Browse files
committed
Coordinator: spawn async task for expensive hash work
1 parent 7ae4ef2 commit 4e3dfb9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/adapter/src/coord/command_handler.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,17 @@ impl Coordinator {
544544
}
545545
if let Some(auth) = self.catalog().try_get_role_auth_by_id(&role.id) {
546546
if let Some(hash) = &auth.password_hash {
547-
let _ = match mz_auth::hash::scram256_verify(&password, hash) {
548-
Ok(_) => tx.send(Ok(AuthResponse {
549-
role_id: role.id,
550-
superuser: role.attributes.superuser.unwrap_or(false),
551-
})),
552-
Err(_) => tx.send(Err(AdapterError::AuthenticationError(
553-
AuthenticationError::InvalidCredentials,
554-
))),
555-
};
547+
let hash = hash.clone();
548+
let role_id = role.id;
549+
let superuser = role.attributes.superuser.unwrap_or(false);
550+
task::spawn(|| "auth-check-hash", async move {
551+
let _ = match mz_auth::hash::scram256_verify(&password, &hash) {
552+
Ok(_) => tx.send(Ok(AuthResponse { role_id, superuser })),
553+
Err(_) => tx.send(Err(AdapterError::AuthenticationError(
554+
AuthenticationError::InvalidCredentials,
555+
))),
556+
};
557+
});
556558
return;
557559
}
558560
}

0 commit comments

Comments
 (0)