Commit 8bff0f86 authored by Vincent Pelletier's avatar Vincent Pelletier

By default, don't drop locked transactions.

This change has an important effect on "abort" call in client handler: once
primary master node locked a transaction, a client must not be allowed to
abort it (it already asked to commit).
Also, remove parameter value in abortFor (it is the new default behaviour).
Also, document abort a bit more.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2417 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent fb7c3664
...@@ -227,9 +227,12 @@ class TransactionManager(object): ...@@ -227,9 +227,12 @@ class TransactionManager(object):
transaction = self._transaction_dict[tid] transaction = self._transaction_dict[tid]
transaction.addObject(oid, compression, checksum, data, value_serial) transaction.addObject(oid, compression, checksum, data, value_serial)
def abort(self, tid, even_if_locked=True): def abort(self, tid, even_if_locked=False):
""" """
Abort a transaction Abort a transaction
Releases locks held on all transaction objects, deletes Transaction
instance, and executed queued events.
Note: does not alter persistent content.
""" """
if tid not in self._transaction_dict: if tid not in self._transaction_dict:
# the tid may be unknown as the transaction is aborted on every node # the tid may be unknown as the transaction is aborted on every node
...@@ -265,7 +268,7 @@ class TransactionManager(object): ...@@ -265,7 +268,7 @@ class TransactionManager(object):
""" """
# abort any non-locked transaction of this node # abort any non-locked transaction of this node
for tid in [x.getTID() for x in self._uuid_dict.get(uuid, [])]: for tid in [x.getTID() for x in self._uuid_dict.get(uuid, [])]:
self.abort(tid, even_if_locked=False) self.abort(tid)
# cleanup _uuid_dict if no transaction remains for this node # cleanup _uuid_dict if no transaction remains for this node
transaction_set = self._uuid_dict.get(uuid) transaction_set = self._uuid_dict.get(uuid)
if transaction_set is not None and not transaction_set: if transaction_set is not None and not transaction_set:
......
...@@ -263,7 +263,7 @@ class TransactionManagerTests(NeoUnitTestBase): ...@@ -263,7 +263,7 @@ class TransactionManagerTests(NeoUnitTestBase):
# lock transaction # lock transaction
self.manager.lock(tid, txn[0]) self.manager.lock(tid, txn[0])
self.assertTrue(tid in self.manager) self.assertTrue(tid in self.manager)
self.manager.abort(tid, even_if_locked=False) self.manager.abort(tid)
self.assertTrue(tid in self.manager) self.assertTrue(tid in self.manager)
for oid in txn[0]: for oid in txn[0]:
self.assertTrue(self.manager.loadLocked(oid)) self.assertTrue(self.manager.loadLocked(oid))
......
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