Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server/src/data_model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,8 @@ pub enum RequestFailureReason {
ConstraintUnsatisfiable,
// Cancelled.
Cancelled,
// Out of memory.
OutOfMemory,
}

impl Display for RequestFailureReason {
Expand All @@ -829,6 +831,7 @@ impl Display for RequestFailureReason {
RequestFailureReason::RequestError => "RequestError",
RequestFailureReason::ConstraintUnsatisfiable => "ConstraintUnsatisfiable",
RequestFailureReason::Cancelled => "Cancelled",
RequestFailureReason::OutOfMemory => "OutOfMemory",
};
write!(f, "{str_val}")
}
Expand All @@ -854,7 +857,7 @@ impl From<FunctionRunFailureReason> for RequestFailureReason {
FunctionRunFailureReason::ConstraintUnsatisfiable => {
RequestFailureReason::ConstraintUnsatisfiable
}
FunctionRunFailureReason::OutOfMemory => RequestFailureReason::FunctionError,
FunctionRunFailureReason::OutOfMemory => RequestFailureReason::OutOfMemory,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions server/src/http_objects_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ pub enum RequestFailureReason {
RequestError,
ConstraintUnsatisfiable,
Cancelled,
OutOfMemory,
}

impl From<data_model::RequestFailureReason> for RequestFailureReason {
Expand All @@ -278,6 +279,7 @@ impl From<data_model::RequestFailureReason> for RequestFailureReason {
RequestFailureReason::ConstraintUnsatisfiable
}
data_model::RequestFailureReason::Cancelled => RequestFailureReason::Cancelled,
data_model::RequestFailureReason::OutOfMemory => RequestFailureReason::OutOfMemory,
}
}
}
Expand Down
77 changes: 77 additions & 0 deletions server/src/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ mod tests {
ApplicationState,
FunctionRunFailureReason,
FunctionRunOutcome,
RequestFailureReason,
RequestOutcome,
test_objects::tests::{
TEST_EXECUTOR_ID,
TEST_NAMESPACE,
Expand Down Expand Up @@ -1086,4 +1088,79 @@ mod tests {
assert_eq!("2", versions.iter().next().unwrap());
Ok(())
}

#[tokio::test]
async fn test_request_failure_reason_out_of_memory() -> Result<()> {
let test_srv = testing::TestService::new().await?;
let Service { indexify_state, .. } = test_srv.service.clone();

// Invoke the app
let request_id = test_state_store::with_simple_application(&indexify_state).await;
test_srv.process_all_state_changes().await?;

// register executor
let executor = test_srv
.create_executor(mock_executor_metadata(TEST_EXECUTOR_ID.into()))
.await?;
test_srv.process_all_state_changes().await?;

// finalize the starting node task with OutOfMemory failure
let desired_state = executor.desired_state().await;
assert_eq!(desired_state.allocations.len(), 1);
let allocation = desired_state.allocations.first().unwrap();
executor
.finalize_allocation(
allocation,
FinalizeFunctionRunArgs::new(
allocation_key_from_proto(allocation),
Some(mock_updates()),
None,
)
.function_run_outcome(FunctionRunOutcome::Failure(
FunctionRunFailureReason::OutOfMemory,
)),
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: OOM test should not emit graph updates

The test_request_failure_reason_out_of_memory test provides graph updates when finalizing a function run that failed due to OutOfMemory. A function failing with OOM shouldn't produce graph updates, which is inconsistent with other failure test patterns.

Fix in Cursor Fix in Web

.await?;
test_srv.process_all_state_changes().await?;

// check that the request outcome is Failure(OutOfMemory)
let request_ctx = indexify_state
.reader()
.request_ctx(TEST_NAMESPACE, "graph_A", &request_id)?
.unwrap();

assert_eq!(
request_ctx.outcome,
Some(RequestOutcome::Failure(RequestFailureReason::OutOfMemory))
);

// check that function_runs have the same failure reason
let function_runs = request_ctx
.function_runs
.values()
.cloned()
.collect::<Vec<_>>();
assert_eq!(function_runs.len(), 1);
let function_run = &function_runs[0];
assert_eq!(
function_run.outcome,
Some(FunctionRunOutcome::Failure(
FunctionRunFailureReason::OutOfMemory
))
);

// check that allocations have the same failure reason
let allocations = indexify_state
.reader()
.get_allocations_by_request_id(TEST_NAMESPACE, "graph_A", &request_id)
.unwrap();
assert_eq!(allocations.len(), 1);
let allocation = &allocations[0];
assert_eq!(
allocation.outcome,
FunctionRunOutcome::Failure(FunctionRunFailureReason::OutOfMemory)
);

Ok(())
}
}