dispersy icon indicating copy to clipboard operation
dispersy copied to clipboard

Error when changing meta messages on community upgrade

Open devos50 opened this issue 7 years ago • 1 comments

When changing the name of meta messages when modifying an existing community, Dispersy throws an error when initializing this community. I found this out when I was working on the TradeChainCommunity, used in the decentralized market: this TradeChain first used the 'old' MultiChain code but I changed this to the true halves implementation of @Captain-Coder. Between these implementations, several meta messages were removed, however these meta messages were still available in the meta_messages table in the Dispersy database:

2017-04-09T20:19:11+0200 [-] Unhandled Error
	Traceback (most recent call last):
	  File "/Library/Python/2.7/site-packages/twisted/internet/base.py", line 420, in fireEvent
	    DeferredList(beforeResults).addCallback(self._continueFiring)
	  File "/Library/Python/2.7/site-packages/twisted/internet/defer.py", line 319, in addCallback
	    callbackKeywords=kw)
	  File "/Library/Python/2.7/site-packages/twisted/internet/defer.py", line 308, in addCallbacks
	    self._runCallbacks()
	  File "/Library/Python/2.7/site-packages/twisted/internet/defer.py", line 651, in _runCallbacks
	    current.result = callback(current.result, *args, **kw)
	--- <exception caught here> ---
	  File "/Library/Python/2.7/site-packages/twisted/internet/base.py", line 433, in _continueFiring
	    callable(*args, **kwargs)
	  File "/Users/martijndevos/Documents/tribler/twisted/plugins/tribler_plugin.py", line 108, in start_tribler
	    self.session.start().addErrback(lambda failure: self.shutdown_process(failure.getErrorMessage()))
	  File "/Users/martijndevos/Documents/tribler/Tribler/dispersy/util.py", line 46, in helper
	    return blockingCallFromThread(reactor, func, *args, **kargs)
	  File "/Users/martijndevos/Documents/tribler/Tribler/dispersy/util.py", line 225, in blockingCallFromThread
	    return f(*args, **kwargs)
	  File "/Users/martijndevos/Documents/tribler/Tribler/Core/Session.py", line 573, in start
	    startup_deferred = self.lm.register(self, self.sesslock)
	  File "/Users/martijndevos/Documents/tribler/Tribler/Core/APIImplementation/LaunchManyCore.py", line 178, in register
	    self.init()
	  File "/Users/martijndevos/Documents/tribler/Tribler/Core/APIImplementation/LaunchManyCore.py", line 309, in init
	    self.load_communities()
	  File "/Users/martijndevos/Documents/tribler/Tribler/dispersy/util.py", line 46, in helper
	    return blockingCallFromThread(reactor, func, *args, **kargs)
	  File "/Users/martijndevos/Documents/tribler/Tribler/dispersy/util.py", line 225, in blockingCallFromThread
	    return f(*args, **kwargs)
	  File "/Users/martijndevos/Documents/tribler/Tribler/Core/APIImplementation/LaunchManyCore.py", line 267, in load_communities
	    kargs=default_kwargs)
	  File "/Users/martijndevos/Documents/tribler/Tribler/dispersy/dispersy.py", line 413, in define_auto_load
	    community = community_cls.init_community(self, master, my_member, *args, **kargs)
	  File "/Users/martijndevos/Documents/tribler/Tribler/dispersy/community.py", line 226, in init_community
	    community.initialize(*args, **kargs)
	  File "/Users/martijndevos/Documents/tribler/Tribler/community/tradechain/community.py", line 56, in initialize
	    super(TradeChainCommunity, self).initialize()
	  File "/Users/martijndevos/Documents/tribler/Tribler/dispersy/community.py", line 376, in initialize
	    self._meta_messages[name]._database_id = database_id  # cleanup pre-fetched values
	exceptions.KeyError: u'crawl_resume'

It works when I manually remove these messages from the Dispersy database.

I think this can be fixed easily :)

devos50 avatar Apr 09 '17 18:04 devos50

I'm unsure if I would qualify this as a bug. I would say that it is not expected that future versions of a community ever remove message types. In such cases of incompatibillity, it would have to update the community master member. When you made your trade community from the multichain community, you should have updated the master member key. Even if you inherit from the multichain community, i'd advise a new master member to keep them separated.

Captain-Coder avatar Apr 23 '17 10:04 Captain-Coder