Commit 7aecdada authored by Julien Muchembled's avatar Julien Muchembled

storage: fix crash when a client disconnects just after it requested to finish a transaction

parent b05b961b
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from time import time from time import time
from neo.lib import logging from neo.lib import logging
from neo.lib.util import dump from neo.lib.util import dump
from neo.lib.protocol import uuid_str, ZERO_TID from neo.lib.protocol import ProtocolError, uuid_str, ZERO_TID
class ConflictError(Exception): class ConflictError(Exception):
""" """
...@@ -183,7 +183,10 @@ class TransactionManager(object): ...@@ -183,7 +183,10 @@ class TransactionManager(object):
Lock a transaction Lock a transaction
""" """
logging.debug('Lock TXN %s (ttid=%s)', dump(tid), dump(ttid)) logging.debug('Lock TXN %s (ttid=%s)', dump(tid), dump(ttid))
try:
transaction = self._transaction_dict[ttid] transaction = self._transaction_dict[ttid]
except KeyError:
raise ProtocolError("unknown ttid %s" % dump(ttid))
# remember that the transaction has been locked # remember that the transaction has been locked
transaction.lock() transaction.lock()
self._load_lock_dict.update( self._load_lock_dict.update(
...@@ -339,6 +342,10 @@ class TransactionManager(object): ...@@ -339,6 +342,10 @@ class TransactionManager(object):
Abort any non-locked transaction of a node Abort any non-locked transaction of a node
""" """
logging.debug('Abort for %s', uuid_str(uuid)) logging.debug('Abort for %s', uuid_str(uuid))
# BUG: Discarding voted transactions must only be a decision of the
# master, and for this, we'll need to review how transactions are
# aborted. As a workaround, we rely on the fact that lock() will
# disconnect from the master in case of LockInformation.
# abort any non-locked transaction of this node # abort any non-locked transaction of this node
for ttid in [x.getTTID() for x in self._uuid_dict.get(uuid, [])]: for ttid in [x.getTTID() for x in self._uuid_dict.get(uuid, [])]:
self.abort(ttid) self.abort(ttid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment