Tribler / dispersy

The elastic database system. A database designed for P2P-like scenarios, where potentially millions of computers send database updates around.
http://www.tribler.org
87 stars 43 forks source link

Error when changing meta messages on community upgrade #536

Open devos50 opened 7 years ago

devos50 commented 7 years ago

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 :)

Captain-Coder commented 7 years ago

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.