Skip to content

Commit fd14243

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

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/adapter/src/coord/command_handler.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,20 @@ 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_blocking(
551+
|| "auth-check-hash",
552+
move || {
553+
let _ = match mz_auth::hash::scram256_verify(&password, &hash) {
554+
Ok(_) => tx.send(Ok(AuthResponse { role_id, superuser })),
555+
Err(_) => tx.send(Err(AdapterError::AuthenticationError(
556+
AuthenticationError::InvalidCredentials,
557+
))),
558+
};
559+
},
560+
);
556561
return;
557562
}
558563
}

0 commit comments

Comments
 (0)