diff options
author | Alex Auvolat <alex@adnab.me> | 2021-03-11 18:55:17 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-03-11 18:56:18 +0100 |
commit | f7c2cd1cd7ee15b9c97b9fbdef25c0644b3523bb (patch) | |
tree | a7fa1d6c1e6ce7df5f61a14e248315288aa2740a /src/table/sync.rs | |
parent | fae5104a2cf91206f995b183c5f217ea6729a551 (diff) | |
download | garage-f7c2cd1cd7ee15b9c97b9fbdef25c0644b3523bb.tar.gz garage-f7c2cd1cd7ee15b9c97b9fbdef25c0644b3523bb.zip |
Add comment, and also whoops, this wasn't doing what we expected
Diffstat (limited to 'src/table/sync.rs')
-rw-r--r-- | src/table/sync.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/table/sync.rs b/src/table/sync.rs index 68fc9fcb..b5044a4e 100644 --- a/src/table/sync.rs +++ b/src/table/sync.rs @@ -440,9 +440,13 @@ where warn!("Hashes differ between stored value and Merkle tree, key: {:?} (if your server is very busy, don't worry, this happens when the Merkle tree can't be updated fast enough)", ik); } todo_items.push(val.to_vec()); + } else { + warn!("Item from Merkle tree not found in store: {:?} (if your server is very busy, don't worry, this happens when the Merkle tree can't be updated fast enough)", ik); } } MerkleNode::Intermediate(l) => { + // Get Merkle node for this tree position at remote node + // and compare it with local node let remote_node = match self .aux .rpc_client @@ -462,7 +466,11 @@ where } }; let int_l2 = match remote_node { + // If they have an intermediate node at this tree position, + // we can compare them to find differences MerkleNode::Intermediate(l2) => l2, + // Otherwise, treat it as if they have nothing for this subtree, + // which will have the consequence of sending them everything _ => vec![], }; @@ -493,20 +501,18 @@ where Ok(()) } - async fn send_items(&self, who: UUID, item_list: Vec<Vec<u8>>) -> Result<(), Error> { + async fn send_items(&self, who: UUID, item_value_list: Vec<Vec<u8>>) -> Result<(), Error> { info!( "({}) Sending {} items to {:?}", self.data.name, - item_list.len(), + item_value_list.len(), who ); - let mut values = vec![]; - for item in item_list.iter() { - if let Some(v) = self.data.store.get(&item[..])? { - values.push(Arc::new(ByteBuf::from(v.as_ref()))); - } - } + let values = item_value_list.into_iter() + .map(|x| Arc::new(ByteBuf::from(x))) + .collect::<Vec<_>>(); + let rpc_resp = self .aux .rpc_client |