diff options
author | Alex Auvolat <alex@adnab.me> | 2023-11-15 12:15:58 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-11-15 12:15:58 +0100 |
commit | b3e729f4b8ec3b06593f8d3b161c76b1263d9f13 (patch) | |
tree | 4c0d403a5bb961a4edb7e1e7462700a400ac4455 /src/rpc/layout/history.rs | |
parent | 7ef2c231208073db5a0a0a8674e2dd2d2ecb2222 (diff) | |
download | garage-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.rs | 18 |
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); |