Skip to content

Commit

Permalink
Use custom error code when rejecting requests in Funrun (#23542)
Browse files Browse the repository at this point in the history
This will allow us to retry actions that were immediately rejected due to server overload safely.

GitOrigin-RevId: 2636064e7f1ffcc24d91f24992bdd03095bc07cc
  • Loading branch information
Preslav Le authored and Convex, Inc. committed Mar 20, 2024
1 parent 1d3b75c commit 70ec185
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/function_runner/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ mod tests {
let response =
FunctionRunnerCore::<TestRuntime, Arc<dyn Storage>>::receive_response(rx2).await?;
let err = response.unwrap_err();
assert!(err.is_overloaded());
assert!(err.is_rejected_before_execution());
assert!(err.to_string().contains(NO_AVAILABLE_WORKERS));
Ok(())
}
Expand Down Expand Up @@ -639,7 +639,7 @@ mod tests {
let response =
FunctionRunnerCore::<TestRuntime, Arc<dyn Storage>>::receive_response(rx2).await?;
let err = response.unwrap_err();
assert!(err.is_overloaded());
assert!(err.is_rejected_before_execution());
assert!(err.to_string().contains(NO_AVAILABLE_WORKERS));
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions crates/isolate/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,9 @@ impl<RT: Runtime> Request<RT> {
}

fn reject(self) {
// TODO: Create a concrete error type for this so FunRun knows when to respond
// with a gRPC RESOURCE_EXHAUSTED code.
let error = ErrorMetadata::overloaded("WorkerOverloaded", NO_AVAILABLE_WORKERS).into();
let error =
ErrorMetadata::rejected_before_execution("WorkerOverloaded", NO_AVAILABLE_WORKERS)
.into();
match self.inner {
RequestType::Udf { response, .. } => {
let _ = response.send(Err(error));
Expand Down

0 comments on commit 70ec185

Please sign in to comment.