mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-25 00:50:36 +00:00
## Problem Pageserver restarts cause read availablity downtime for tenants. See `Motivation` section in the [RFC](https://github.com/neondatabase/neon/pull/7704). ## Summary of changes * Introduce a new `NodeSchedulingPolicy`: `PauseForRestart` * Implement the first take of drain and fill algorithms * Add a node status endpoint which can be polled to figure out when an operation is done The implementation follows the RFC, so it might be useful to peek at it as you're reviewing. Since the PR is rather chunky, I've made sure all commits build (with warnings), so you can review by commit if you prefer that. RFC: https://github.com/neondatabase/neon/pull/7704 Related https://github.com/neondatabase/neon/issues/7387
60 lines
1.4 KiB
Rust
60 lines
1.4 KiB
Rust
use std::{borrow::Cow, fmt::Debug, fmt::Display};
|
|
|
|
use tokio_util::sync::CancellationToken;
|
|
use utils::id::NodeId;
|
|
|
|
pub(crate) const MAX_RECONCILES_PER_OPERATION: usize = 10;
|
|
|
|
#[derive(Copy, Clone)]
|
|
pub(crate) struct Drain {
|
|
pub(crate) node_id: NodeId,
|
|
}
|
|
|
|
#[derive(Copy, Clone)]
|
|
pub(crate) struct Fill {
|
|
pub(crate) node_id: NodeId,
|
|
}
|
|
|
|
#[derive(Copy, Clone)]
|
|
pub(crate) enum Operation {
|
|
Drain(Drain),
|
|
Fill(Fill),
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub(crate) enum OperationError {
|
|
#[error("Node state changed during operation: {0}")]
|
|
NodeStateChanged(Cow<'static, str>),
|
|
#[error("Operation finalize error: {0}")]
|
|
FinalizeError(Cow<'static, str>),
|
|
#[error("Operation cancelled")]
|
|
Cancelled,
|
|
}
|
|
|
|
pub(crate) struct OperationHandler {
|
|
pub(crate) operation: Operation,
|
|
#[allow(unused)]
|
|
pub(crate) cancel: CancellationToken,
|
|
}
|
|
|
|
impl Display for Drain {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
write!(f, "drain {}", self.node_id)
|
|
}
|
|
}
|
|
|
|
impl Display for Fill {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
write!(f, "fill {}", self.node_id)
|
|
}
|
|
}
|
|
|
|
impl Display for Operation {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
match self {
|
|
Operation::Drain(op) => write!(f, "{op}"),
|
|
Operation::Fill(op) => write!(f, "{op}"),
|
|
}
|
|
}
|
|
}
|