Include old_versions when merging layouts, don't remove old layout versions #854

Closed
dominik wants to merge 3 commits from dominik/garage:historical_layout_fix into main
2 changed files with 13 additions and 11 deletions

View file

@ -107,11 +107,6 @@ impl LayoutHistory {
);
self.old_versions.push(removed);
}
while self.old_versions.len() > OLD_VERSION_COUNT {
let removed = self.old_versions.remove(0);
info!("Layout history: removing old_version {}", removed.version);
}
}
pub(crate) fn clamp_update_trackers(&mut self, nodes: &[Uuid]) {
@ -230,13 +225,23 @@ impl LayoutHistory {
let mut changed = false;
// Add any new versions to history
for v2 in other.versions.iter() {
if let Some(v1) = self.versions.iter().find(|v| v.version == v2.version) {
for v2 in other.old_versions.iter().chain(other.versions.iter()) {
if let Some(v1) = self
.old_versions
.iter()
.chain(self.versions.iter())
.find(|v| v.version == v2.version)
{
// Version is already present, check consistency
if v1 != v2 {
error!("Inconsistent layout histories: different layout compositions for version {}. Your cluster will be broken as long as this layout version is not replaced.", v2.version);
}
} else if self.versions.iter().all(|v| v.version != v2.version - 1) {
} else if self
.old_versions
.iter()
.chain(self.versions.iter())
.all(|v| v.version != v2.version - 1)
{
error!(
"Cannot receive new layout version {}, version {} is missing",
v2.version,

View file

@ -231,9 +231,6 @@ mod v010 {
use std::collections::BTreeMap;
pub use v09::{LayoutParameters, NodeRole, NodeRoleV, ZoneRedundancy};
/// Number of old (non-live) versions to keep, see LayoutHistory::old_versions
pub const OLD_VERSION_COUNT: usize = 5;
/// The history of cluster layouts, with trackers to keep a record
/// of which nodes are up-to-date to current cluster data
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]