aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/layout/history.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-11-15 12:15:58 +0100
committerAlex Auvolat <alex@adnab.me>2023-11-15 12:15:58 +0100
commitb3e729f4b8ec3b06593f8d3b161c76b1263d9f13 (patch)
tree4c0d403a5bb961a4edb7e1e7462700a400ac4455 /src/rpc/layout/history.rs
parent7ef2c231208073db5a0a0a8674e2dd2d2ecb2222 (diff)
downloadgarage-b3e729f4b8ec3b06593f8d3b161c76b1263d9f13.tar.gz
garage-b3e729f4b8ec3b06593f8d3b161c76b1263d9f13.zip
layout history merge: rm invalid versions when valid versions are added
Diffstat (limited to 'src/rpc/layout/history.rs')
-rw-r--r--src/rpc/layout/history.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/rpc/layout/history.rs b/src/rpc/layout/history.rs
index dce492c9..2346b14a 100644
--- a/src/rpc/layout/history.rs
+++ b/src/rpc/layout/history.rs
@@ -211,6 +211,24 @@ impl LayoutHistory {
changed = changed || c;
}
+ // If there are invalid versions before valid versions, remove them,
+ // and increment update trackers
+ if self.versions.len() > 1 && self.current().check().is_ok() {
+ while self.versions.first().unwrap().check().is_err() {
+ self.versions.remove(0);
+ changed = true;
+ }
+ if changed {
+ let min_v = self.versions.first().unwrap().version;
+ let nodes = self.all_nongateway_nodes().into_owned();
+ for node in nodes {
+ self.update_trackers.ack_map.set_max(node, min_v);
+ self.update_trackers.sync_map.set_max(node, min_v);
+ self.update_trackers.sync_ack_map.set_max(node, min_v);
+ }
+ }
+ }
+
// Merge staged layout changes
if self.staging != other.staging {
self.staging.merge(&other.staging);