From a23b0abf28591e1dab79e2dcfc32c6e591a9f259 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 25 Jun 2024 10:32:34 -0400 Subject: [PATCH] PUT to cluster send to all nodes rather than none If the location log says all nodes contain content, pass in all nodes, rather than none. The location log can be wrong. While it's good to avoid unncessessary connections to nodes that already contain a key, it would be bad to refuse to accept an upload at all when the location log is wrong. Also, passing in no nodes leaves the proxy in an untenable state. It can't proxy to no nodes. So it closes the connection. Passing in all nodes means it has to do the work to connect to all of them, and see that they say they already have the content, and then it can tell the client that. --- Annex/Cluster.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Annex/Cluster.hs b/Annex/Cluster.hs index 10125e9c5f..4f60f6ca25 100644 --- a/Annex/Cluster.hs +++ b/Annex/Cluster.hs @@ -67,10 +67,15 @@ clusterProxySelector clusteruuid protocolversion = do return $ ProxySelector { proxyCHECKPRESENT = nodecontaining remotesides , proxyGET = nodecontaining remotesides - -- Send the key to every node that does not yet contain it. + -- The key is sent to multiple nodes at the same time, + -- skipping nodes where it's known/expected to already be + -- present to avoid needing to connect to those. , proxyPUT = \k -> do locs <- S.fromList <$> loggedLocations k - return $ filter (flip S.notMember locs . remoteUUID) remotesides + let l = filter (flip S.notMember locs . remoteUUID) remotesides + return $ if null l + then remotesides + else l -- Remove the key from every node that contains it. -- But, since it's possible the location log for some nodes -- could be out of date, actually try to remove from every -- 2.39.5