Skip to content

Commit

Permalink
storcon: clear generation_pageserver when detaching
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsp committed Dec 4, 2024
1 parent e6cd505 commit 60ed9fa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions storage_controller/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,21 @@ impl Persistence {
.into_boxed(),
};

// Clear generation_pageserver if we are moving into a state where we won't have
// any attached pageservers.
let input_generation_pageserver = match input_placement_policy {
None | Some(PlacementPolicy::Attached(_)) => None,
Some(PlacementPolicy::Detached | PlacementPolicy::Secondary) => Some(None),
};

#[derive(AsChangeset)]
#[diesel(table_name = crate::schema::tenant_shards)]
struct ShardUpdate {
generation: Option<i32>,
placement_policy: Option<String>,
config: Option<String>,
scheduling_policy: Option<String>,
generation_pageserver: Option<Option<i64>>,
}

let update = ShardUpdate {
Expand All @@ -655,6 +663,7 @@ impl Persistence {
.map(|c| serde_json::to_string(&c).unwrap()),
scheduling_policy: input_scheduling_policy
.map(|p| serde_json::to_string(&p).unwrap()),
generation_pageserver: input_generation_pageserver,
};

query.set(update).execute(conn)?;
Expand Down

0 comments on commit 60ed9fa

Please sign in to comment.