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

Add grace duration and kill process #487

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Reply to stop msg immediately to coordinator
  • Loading branch information
haixuanTao committed Apr 30, 2024
commit a631cafe5277b7b188b4749b9039cc3386a7c0b4
2 changes: 1 addition & 1 deletion binaries/coordinator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ async fn stop_dataflow(
other => bail!("unexpected reply after sending stop: {other:?}"),
}
}
tracing::info!("successfully stopped dataflow `{uuid}`");
tracing::info!("successfully send stop dataflow `{uuid}` to all daemons");

Ok(())
}
Expand Down
26 changes: 9 additions & 17 deletions binaries/daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl Daemon {
}
Event::CtrlC => {
for dataflow in self.running.values_mut() {
dataflow.stop_all(&self.clock, None, None).await;
dataflow.stop_all(&self.clock, None).await;
}
}
}
Expand Down Expand Up @@ -438,9 +438,13 @@ impl Daemon {
.get_mut(&dataflow_id)
.wrap_err_with(|| format!("no running dataflow with ID `{dataflow_id}`"))?;
// .stop_all(&self.clock.clone(), grace_duration);
dataflow
.stop_all(&self.clock, grace_duration, Some(reply_tx))
.await;

let reply = DaemonCoordinatorReply::StopResult(Ok(()));
let _ = reply_tx
.send(Some(reply))
.map_err(|_| error!("could not send stop reply from daemon to coordinator"));

dataflow.stop_all(&self.clock, grace_duration).await;
RunStatus::Continue
}
DaemonCoordinatorEvent::Destroy => {
Expand Down Expand Up @@ -1427,12 +1431,7 @@ impl RunningDataflow {
Ok(())
}

async fn stop_all(
&mut self,
clock: &HLC,
grace_duration: Option<Duration>,
reply_tx: Option<Sender<Option<DaemonCoordinatorReply>>>,
) {
async fn stop_all(&mut self, clock: &HLC, grace_duration: Option<Duration>) {
for (_node_id, channel) in self.subscribe_channels.drain() {
let _ = send_with_timestamp(&channel, daemon_messages::NodeEvent::Stop, clock);
}
Expand All @@ -1453,13 +1452,6 @@ impl RunningDataflow {
)
}
}

let reply = DaemonCoordinatorReply::StopResult(Ok(()));
if let Some(tx) = reply_tx {
let _ = tx
.send(Some(reply))
.map_err(|_| error!("could not send stop reply from daemon to coordinator"));
}
});
self.stop_sent = true;
}
Expand Down