Skip to content

graphman: pause subgraph before reassigning #5256

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions node/src/manager/commands/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ pub fn reassign(
let site = conn
.locate_site(locator.clone())?
.ok_or_else(|| anyhow!("failed to locate site for {locator}"))?;

let (_, is_paused) = conn
.assignment_status(&site)?
.ok_or_else(|| anyhow!("failed to locate site for {locator}"))?;

// pause the subgraph before reassigning to avoid racing conditions
if !is_paused {
conn.pause_subgraph(&site)?;
}

let changes = match conn.assigned_node(&site)? {
Some(cur) => {
if cur == node {
Expand All @@ -60,6 +70,11 @@ pub fn reassign(
};
conn.send_store_event(sender, &StoreEvent::new(changes))?;

// resume subgraph if we paused it
if !is_paused {
conn.resume_subgraph(&site)?;
}

// It's easy to make a typo in the name of the node; if this operation
// assigns to a node that wasn't used before, warn the user that they
// might have mistyped the node name
Expand Down