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.
This commit is contained in:
Joey Hess 2024-06-25 10:32:34 -04:00
parent 202ea3ff2a
commit a23b0abf28
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -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