mirror of
https://github.com/neondatabase/neon.git
synced 2026-07-13 17:10:39 +00:00
DNM dirty hacks
This commit is contained in:
@@ -612,6 +612,8 @@ async fn handle_tenant_create(mut req: Request<Body>) -> Result<Response<Body>,
|
||||
})?;
|
||||
}
|
||||
|
||||
locked.save().await.map_err(ApiError::InternalServerError)?;
|
||||
|
||||
json_response(
|
||||
StatusCode::OK,
|
||||
TenantCreateResponse {
|
||||
@@ -842,6 +844,17 @@ async fn handle_tenant_shard_split(mut req: Request<Body>) -> Result<Response<Bo
|
||||
))
|
||||
})?;
|
||||
|
||||
tracing::info!(
|
||||
"Split {} into {}",
|
||||
tenant_shard_id,
|
||||
response
|
||||
.new_shards
|
||||
.iter()
|
||||
.map(|s| format!("{:?}", s))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
);
|
||||
|
||||
replacements.insert(*tenant_shard_id, response.new_shards);
|
||||
}
|
||||
|
||||
@@ -863,6 +876,8 @@ async fn handle_tenant_shard_split(mut req: Request<Body>) -> Result<Response<Bo
|
||||
)
|
||||
};
|
||||
|
||||
locked.tenants.remove(&replaced);
|
||||
|
||||
for child in children {
|
||||
let mut child_shard = shard_ident;
|
||||
child_shard.number = child.shard_number;
|
||||
@@ -902,6 +917,8 @@ async fn handle_tenant_shard_split(mut req: Request<Body>) -> Result<Response<Bo
|
||||
}
|
||||
}
|
||||
|
||||
locked.save().await.map_err(ApiError::InternalServerError)?;
|
||||
|
||||
json_response(StatusCode::OK, response)
|
||||
}
|
||||
|
||||
|
||||
@@ -544,6 +544,10 @@ async fn handle_tenant(
|
||||
|
||||
let attachment_service = AttachmentService::from_env(env);
|
||||
for shard in attachment_service.tenant_locate(tenant_id).await?.shards {
|
||||
println!(
|
||||
"Getting status for {} from {}",
|
||||
shard.shard_id, shard.node_id
|
||||
);
|
||||
let pageserver =
|
||||
PageServerNode::from_env(env, env.get_pageserver_conf(shard.node_id)?);
|
||||
|
||||
@@ -554,8 +558,10 @@ async fn handle_tenant(
|
||||
.tenant_info
|
||||
.current_physical_size
|
||||
.unwrap();
|
||||
|
||||
println!("add_row",);
|
||||
shard_table.add_row([
|
||||
format!("{}", shard.shard_id.shard_number.0),
|
||||
format!("{}", shard.shard_id),
|
||||
format!("{}", shard.node_id.0),
|
||||
format!("{}", size),
|
||||
]);
|
||||
@@ -585,9 +591,19 @@ async fn handle_tenant(
|
||||
let shard_count: u8 = matches.get_one::<u8>("shard-count").cloned().unwrap_or(0);
|
||||
|
||||
let attachment_service = AttachmentService::from_env(env);
|
||||
attachment_service
|
||||
let result = attachment_service
|
||||
.tenant_split(tenant_id, shard_count)
|
||||
.await?;
|
||||
println!(
|
||||
"Split tenant {} into shards {}",
|
||||
tenant_id,
|
||||
result
|
||||
.new_shards
|
||||
.iter()
|
||||
.map(|s| format!("{:?}", s))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
);
|
||||
}
|
||||
|
||||
Some((sub_name, _)) => bail!("Unexpected tenant subcommand '{}'", sub_name),
|
||||
|
||||
@@ -152,7 +152,7 @@ pub async fn migrate_tenant(
|
||||
|
||||
let cplane = ComputeControlPlane::load(env.clone())?;
|
||||
for (endpoint_name, endpoint) in &cplane.endpoints {
|
||||
if endpoint.tenant_id == tenant_shard_id.tenant_id {
|
||||
if endpoint.tenant_id == tenant_shard_id.tenant_id && endpoint.status() == "running" {
|
||||
println!(
|
||||
"🔁 Reconfiguring endpoint {} to use pageserver {}",
|
||||
endpoint_name, dest_ps.conf.id
|
||||
@@ -178,19 +178,24 @@ pub async fn migrate_tenant(
|
||||
continue;
|
||||
}
|
||||
|
||||
// Downgrade to a secondary location
|
||||
let secondary_conf = build_location_config(
|
||||
LocationConfigMode::Secondary,
|
||||
None,
|
||||
Some(LocationConfigSecondary { warm: true }),
|
||||
);
|
||||
// // Downgrade to a secondary location
|
||||
// let secondary_conf = build_location_config(
|
||||
// LocationConfigMode::Secondary,
|
||||
// None,
|
||||
// Some(LocationConfigSecondary { warm: true }),
|
||||
// );
|
||||
|
||||
println!(
|
||||
"💤 Switching to secondary mode on pageserver {}",
|
||||
other_ps.conf.id
|
||||
);
|
||||
// println!(
|
||||
// "💤 Switching to secondary mode on pageserver {}",
|
||||
// other_ps.conf.id
|
||||
// );
|
||||
// other_ps
|
||||
// .location_config(tenant_shard_id, secondary_conf, None)
|
||||
// .await?;
|
||||
let detached_conf = build_location_config(LocationConfigMode::Detached, None, None);
|
||||
println!("💤 Detaching on pageserver {}", other_ps.conf.id);
|
||||
other_ps
|
||||
.location_config(tenant_shard_id, secondary_conf, None)
|
||||
.location_config(tenant_shard_id, detached_conf, None)
|
||||
.await?;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user