[mnet-devel] patch: blockwrangler bugfix and assertions

Arno Waschk hamamatsu at gmx.de
Tue Feb 17 19:40:12 GMT 2004


cute! we had that bug for a while, no?

On 17 Feb 2004 12:35:23 -0500, Zooko O'Whielacronx <zooko at zooko.com> wrote:

>
> This patch fixes on thing that is probably a bug in blockwrangler -- 
> with this
> patch blocks are removed from peerclaimedblocks when a "request block" 
> resolves.
>
> This patch also adds a bunch of assertions intended to flush out other 
> bugs in
> blockwrangler.  These assertions might cause unnecessary exceptions, but 
> as long
> as you are running with assertion-checking turned off, they can't hurt.
>
> --- common/BlockWrangler.py	7 Dec 2003 17:35:50 -0000	1.94
> +++ common/BlockWrangler.py	17 Feb 2004 17:26:08 -0000
> @@ -303,6 +303,7 @@ class BlockWrangler(nummedobj.NummedObj)
>                  self.data.remove_Ids_of_located_blocks(peerId, 
> blockIds=queryblockIds)
>
>              # Tell the strategy to wake up -- there are new results to 
> consider!  (Even failure is a new result to consider.)
> +            assert self._assert_consistency()
>              self.strategy.schedule_event()
>
>          def _handle_timely_look_for_blocks_result(widget, outcome, 
> failure_reason=None, 
> _handle_look_for_blocks_result=_handle_look_for_blocks_result, 
> peerId=peerId, self=self):
> @@ -357,12 +358,13 @@ class BlockWrangler(nummedobj.NummedObj)
>              assert self.data._assert_consistency()
>              # No matter what comes out of this reply, we are removing 
> this blockId/peerId pair from the located-blocks data.  (Because either 
> this result means that we now have the block, or it means that the peer 
> does not have the block!)
>              self.data.remove_Ids_of_located_blocks(peerId, 
> blockIds=(blockId,))
> +            assert self.data.peerclaimedblock.has_key((peerId, 
> blockId,))
> +            self.data.peerclaimedblock.del_if_present((peerId, 
> blockId,))
>              if failure_reason or (outcome['result'] != "success"):
>                  # Inform reliability handicapper that this was actually 
> a failure.
>                  self.mtm._keeper.get_counterparty_object(peerId).decrement_reliability()
>                  # Wake the block wrangling strategy -- failure to 
> retrieve a block is the kind of thing that it might want to respond to.
>                  self.strategy.schedule_event()
> -                # XXX should we update the peerclaimedblocks struct 
> here?!  --Zooko 2002-12-01
>              else:
>                  self._handle_block(blockId, outcome['data'], peerId)
>
> @@ -653,9 +655,11 @@ class BlockWranglerData(nummedobj.Nummed
>          # For each (peerId, blockId,) tuple in peerclaimedblock, if the 
> peer *has*
>          # claimed the block, then the blockId must appear in 
> bId2peers[blockId],
>          # and if the peer has claimed *not* to have the block then the 
> blockId
> -        # must *not* appear in bId2peers[blockId].
> +        # must *not* appear in bId2peers[blockId].  For each blockId in
> +        # peerclaimedblock, we must currently be wanting that block.
>          for ((peerId, blockId,), claim,) in 
> self.peerclaimedblock.items():
>              assert (claim == 1) == (peerId in 
> self.bId2peers.get(blockId, ()))
> +            assert self.Idsofwantedblocks.has_key(blockId)
>
>          # For each peer which is pointed to by a blockId in bId2peers,
>          # peerclaimedblock[(peer, blockId,)] must equal 1.
> @@ -799,7 +795,7 @@ class BlockWranglerData(nummedobj.Nummed
>          """
>          @precondition: We are required to currently *not* be wanting 
> each of these blocks.: len(filter(lambda x, self=selfXC 
> self.Idsofwantedblocks.has_key(x), blockIds)) == 0
>          """
> -        assert len(filter(lambda x, self=self: 
> self.Idsofwantedblocks.has_key(x), blockIds)) == 0, "precondition: We 
> are required to currently *not* be wanting each of these blocks."
> +        assert len(filter(lambda x, self=self: 
> self.Idsofwantedblocks.has_key(x), blockIds)) == 0, "precondition: We 
> are required to currently *not* be wanting each of these blocks. 
> curwanted: %s" % humanreadable.hr(filter(lambda x, self=self: 
> self.Idsofwantedblocks.has_key(x), blockIds))
>          if len(blockIds) > 0:
>              self.add_Ids_of_wanted_blocks(blockIds)
>
> @@ -818,11 +814,12 @@ class BlockWranglerData(nummedobj.Nummed
>          This has to clean up everything so that internal state is 
> consistent
>          again.  This might be a performance issue.  This gets called 
> whenever we
>          get a block and whenever we complete a chunk reconstruction.  
> Also it
> -        will be called by a "cancel" operation if we add that.
> +        will be called by a "cancel" operation if we add that. (note: 
> we have.  it's called "shoot".  --Zooko 2004-02-17)
>
>          @precondition: You are required to be currently wanting each of 
> these blocks when you call this method.: len(filter(lambda x, 
> self=selfXC not self.Idsofwantedblocks.has_key(x), blockIds)) == 0
>          """
>          assert len(filter(lambda x, self=self: not 
> self.Idsofwantedblocks.has_key(x), blockIds)) == 0, "precondition: You 
> are required to be currently wanting each of these blocks when you call 
> this method."
> +        assert self._assert_consistency()
>
>          if len(blockIds) > 0:
>              for fileobj in filter(lambda x, 
> c=self.bId2chunkobj[blockIds[0]], self=self: c in 
> self.fileobj2chunkobjs[x], self.fileobj2chunkobjs.keys()):
> @@ -855,7 +851,8 @@ class BlockWranglerData(nummedobj.Nummed
>              self.dontneed = self.dontneed + NeedCount
>
>          debugprint("%s.stop_wanting_blocks(%s: %s); I now want %s 
> blocks. I think I still need %s\n", args=(self, len(blockIds), blockIds, 
> len(self.list_Ids_of_wanted_blocks()), self.total-self.dontneed), v=5, 
> vs="BlockWrangler")
> +        assert self._assert_consistency()
>
>      def stop_wanting_blocks_idempotent(self, blockIds, NeedCount=None):
>          """
>
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> mnet-devel mailing list
> mnet-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mnet-devel
>



-- 
http://www.arnowaschk.de


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
mnet-devel mailing list
mnet-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mnet-devel




More information about the Mnet-devel mailing list