mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 09:22:55 +00:00
## Problem Storage controller restarts cause temporary unavailability from the control plane POV. See RFC for more details. ## Summary of changes * A couple of small refactors of the storage controller start-up sequence to make extending it easier. * A leader table is added to track the storage controller instance that's currently the leader (if any) * A peer client is added such that storage controllers can send `step_down` requests to each other (implemented in https://github.com/neondatabase/neon/pull/8512). * Implement the leader cut-over as described in the RFC * Add `start-as-candidate` flag to the storage controller to gate the rolling restart behaviour. When the flag is `false` (the default), the only change from the current start-up sequence is persisting the leader entry to the database.
58 lines
1.1 KiB
Rust
58 lines
1.1 KiB
Rust
use serde::Serialize;
|
|
use utils::seqwait::MonotonicCounter;
|
|
|
|
mod auth;
|
|
mod background_node_operations;
|
|
mod compute_hook;
|
|
mod drain_utils;
|
|
mod heartbeater;
|
|
pub mod http;
|
|
mod id_lock_map;
|
|
pub mod metrics;
|
|
mod node;
|
|
mod pageserver_client;
|
|
mod peer_client;
|
|
pub mod persistence;
|
|
mod reconciler;
|
|
mod scheduler;
|
|
mod schema;
|
|
pub mod service;
|
|
mod tenant_shard;
|
|
|
|
#[derive(Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Serialize)]
|
|
struct Sequence(u64);
|
|
|
|
impl Sequence {
|
|
fn initial() -> Self {
|
|
Self(0)
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for Sequence {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
write!(f, "{}", self.0)
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Debug for Sequence {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
write!(f, "{}", self.0)
|
|
}
|
|
}
|
|
|
|
impl MonotonicCounter<Sequence> for Sequence {
|
|
fn cnt_advance(&mut self, v: Sequence) {
|
|
assert!(*self <= v);
|
|
*self = v;
|
|
}
|
|
fn cnt_value(&self) -> Sequence {
|
|
*self
|
|
}
|
|
}
|
|
|
|
impl Sequence {
|
|
fn next(&self) -> Sequence {
|
|
Sequence(self.0 + 1)
|
|
}
|
|
}
|