From: Zooko O'Whielacronx Date: Mon, 19 Jul 2010 07:54:26 +0000 (-0700) Subject: immutable: fix bug in which preexisting_shares and merged were shallowly referencing... X-Git-Tag: allmydata-tahoe-1.7.1~4 X-Git-Url: https://git.rkrishnan.org/about.html?a=commitdiff_plain;h=13b5e44fbc2effd09f97307540783fbbd47acebe;p=tahoe-lafs%2Ftahoe-lafs.git immutable: fix bug in which preexisting_shares and merged were shallowly referencing the same sets This bug had the effect of making uploads sometimes (rarely) appear to succeed when they had actually not distributed the shares well enough to achieve the desired servers-of-happiness level. --- diff --git a/src/allmydata/util/happinessutil.py b/src/allmydata/util/happinessutil.py index 4c711290..9e5b3705 100644 --- a/src/allmydata/util/happinessutil.py +++ b/src/allmydata/util/happinessutil.py @@ -3,6 +3,8 @@ I contain utilities useful for calculating servers_of_happiness, and for reporting it in messages """ +from copy import deepcopy + def failure_message(peer_count, k, happy, effective_happy): # If peer_count < needed_shares, this error message makes more # sense than any of the others, so use it. @@ -60,16 +62,16 @@ def merge_peers(servermap, used_peers=None): argument to include the shareid -> peerid mappings implied in the set of PeerTrackers, returning the resulting dict. """ + # Since we mutate servermap, and are called outside of a + # context where it is okay to do that, make a copy of servermap and + # work with it. + servermap = deepcopy(servermap) if not used_peers: return servermap assert(isinstance(servermap, dict)) assert(isinstance(used_peers, set)) - # Since we mutate servermap, and are called outside of a - # context where it is okay to do that, make a copy of servermap and - # work with it. - servermap = servermap.copy() for peer in used_peers: for shnum in peer.buckets: servermap.setdefault(shnum, set()).add(peer.peerid)