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

Remove active execution graph when the related job is successful or failed #392

Merged
merged 1 commit into from
Oct 19, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ballista/scheduler/src/scheduler_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,9 @@ mod test {
let graph = scheduler
.state
.task_manager
.get_active_execution_graph(job_id)
.await
.get_job_execution_graph(job_id)
.await?
.unwrap();
let graph = graph.read().await;
if graph.is_successful() {
break;
}
Expand Down
12 changes: 10 additions & 2 deletions ballista/scheduler/src/state/task_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan> TaskManager<T, U>
let lock = self.state.lock(Keyspace::ActiveJobs, "").await?;
with_lock(lock, self.state.delete(Keyspace::ActiveJobs, job_id)).await?;

if let Some(graph) = self.get_active_execution_graph(job_id).await {
if let Some(graph) = self.remove_active_execution_graph(job_id).await {
let graph = graph.read().await.clone();
if graph.is_successful() {
let value = self.encode_execution_graph(graph)?;
Expand Down Expand Up @@ -423,7 +423,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan> TaskManager<T, U>
]
};

let _res = if let Some(graph) = self.get_active_execution_graph(job_id).await {
let _res = if let Some(graph) = self.remove_active_execution_graph(job_id).await {
let mut graph = graph.write().await;
let previous_status = graph.status();
graph.fail_job(failure_reason);
Expand Down Expand Up @@ -592,6 +592,14 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan> TaskManager<T, U>
self.active_job_cache.get(job_id).map(|value| value.clone())
}

/// Remove the `ExecutionGraph` for the given job ID from cache
pub(crate) async fn remove_active_execution_graph(
&self,
job_id: &str,
) -> Option<Arc<RwLock<ExecutionGraph>>> {
self.active_job_cache.remove(job_id).map(|value| value.1)
}

/// Get the `ExecutionGraph` for the given job ID. This will search fist in the `ActiveJobs`
/// keyspace and then, if it doesn't find anything, search the `CompletedJobs` keyspace.
pub(crate) async fn get_execution_graph(
Expand Down