mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-07 13:32:57 +00:00
## Problem We want to do a more robust job of scheduling tenants into their home AZ: https://github.com/neondatabase/neon/issues/8264. Closes: https://github.com/neondatabase/neon/issues/8969 ## Summary of changes ### Scope This PR combines prioritizing AZ with a larger rework of how we do optimisation. The rationale is that just bumping AZ in the order of Score attributes is a very tiny change: the interesting part is lining up all the optimisation logic to respect this properly, which means rewriting it to use the same scores as the scheduler, rather than the fragile hand-crafted logic that we had before. Separating these changes out is possible, but would involve doing two rounds of test updates instead of one. ### Scheduling optimisation `TenantShard`'s `optimize_attachment` and `optimize_secondary` methods now both use the scheduler to pick a new "favourite" location. Then there is some refined logic for whether + how to migrate to it: - To decide if a new location is sufficiently "better", we generate scores using some projected ScheduleContexts that exclude the shard under consideration, so that we avoid migrating from a node with AffinityScore(2) to a node with AffinityScore(1), only to migrate back later. - Score types get a `for_optimization` method so that when we compare scores, we will only do an optimisation if the scores differ by their highest-ranking attributes, not just because one pageserver is lower in utilization. Eventually we _will_ want a mode that does this, but doing it here would make scheduling logic unstable and harder to test, and to do this correctly one needs to know the size of the tenant that one is migrating. - When we find a new attached location that we would like to move to, we will create a new secondary location there, even if we already had one on some other node. This handles the case where we have a home AZ A, and want to migrate the attachment between pageservers in that AZ while retaining a secondary location in some other AZ as well. - A unit test is added for https://github.com/neondatabase/neon/issues/8969, which is implicitly fixed by reworking optimisation to use the same scheduling scores as scheduling.
58 lines
1.3 KiB
TOML
58 lines
1.3 KiB
TOML
[package]
|
|
name = "storage_controller"
|
|
version = "0.1.0"
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
|
|
[[bin]]
|
|
name = "storage_controller"
|
|
path = "src/main.rs"
|
|
|
|
[features]
|
|
default = []
|
|
# Enables test-only APIs and behaviors
|
|
testing = []
|
|
|
|
[dependencies]
|
|
anyhow.workspace = true
|
|
bytes.workspace = true
|
|
chrono.workspace = true
|
|
clap.workspace = true
|
|
fail.workspace = true
|
|
futures.workspace = true
|
|
hex.workspace = true
|
|
hyper0.workspace = true
|
|
humantime.workspace = true
|
|
itertools.workspace = true
|
|
lasso.workspace = true
|
|
once_cell.workspace = true
|
|
pageserver_api.workspace = true
|
|
pageserver_client.workspace = true
|
|
postgres_connection.workspace = true
|
|
rand.workspace = true
|
|
reqwest = { workspace = true, features = ["stream"] }
|
|
routerify.workspace = true
|
|
serde.workspace = true
|
|
serde_json.workspace = true
|
|
thiserror.workspace = true
|
|
tokio.workspace = true
|
|
tokio-util.workspace = true
|
|
tracing.workspace = true
|
|
measured.workspace = true
|
|
scopeguard.workspace = true
|
|
strum.workspace = true
|
|
strum_macros.workspace = true
|
|
|
|
diesel = { version = "2.2.6", features = [
|
|
"serde_json",
|
|
"postgres",
|
|
"r2d2",
|
|
"chrono",
|
|
] }
|
|
diesel_migrations = { version = "2.2.0" }
|
|
r2d2 = { version = "0.8.10" }
|
|
|
|
utils = { path = "../libs/utils/" }
|
|
metrics = { path = "../libs/metrics/" }
|
|
control_plane = { path = "../control_plane" }
|
|
workspace_hack = { version = "0.1", path = "../workspace_hack" } |