Commit 58d0b602 authored by Julien Muchembled's avatar Julien Muchembled

storage: fix abort before vote, to free the storage space used by the transaction

parent d87df377
...@@ -578,11 +578,8 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -578,11 +578,8 @@ class MySQLDatabaseManager(DatabaseManager):
def abortTransaction(self, ttid): def abortTransaction(self, ttid):
ttid = util.u64(ttid) ttid = util.u64(ttid)
q = self.query q = self.query
sql = " FROM tobj WHERE tid=%s" % ttid q("DELETE FROM tobj WHERE tid=%s" % ttid)
data_id_list = [x for x, in q("SELECT data_id" + sql) if x]
q("DELETE" + sql)
q("DELETE FROM ttrans WHERE ttid=%s" % ttid) q("DELETE FROM ttrans WHERE ttid=%s" % ttid)
self.releaseData(data_id_list, True)
def deleteTransaction(self, tid): def deleteTransaction(self, tid):
tid = util.u64(tid) tid = util.u64(tid)
......
...@@ -439,11 +439,8 @@ class SQLiteDatabaseManager(DatabaseManager): ...@@ -439,11 +439,8 @@ class SQLiteDatabaseManager(DatabaseManager):
def abortTransaction(self, ttid): def abortTransaction(self, ttid):
args = util.u64(ttid), args = util.u64(ttid),
q = self.query q = self.query
sql = " FROM tobj WHERE tid=?" q("DELETE FROM tobj WHERE tid=?", args)
data_id_list = [x for x, in q("SELECT data_id" + sql, args) if x]
q("DELETE" + sql, args)
q("DELETE FROM ttrans WHERE ttid=?", args) q("DELETE FROM ttrans WHERE ttid=?", args)
self.releaseData(data_id_list, True)
def deleteTransaction(self, tid): def deleteTransaction(self, tid):
tid = util.u64(tid) tid = util.u64(tid)
......
...@@ -290,7 +290,10 @@ class TransactionManager(object): ...@@ -290,7 +290,10 @@ class TransactionManager(object):
if not even_if_locked: if not even_if_locked:
return return
else: else:
self._app.dm.abortTransaction(ttid) dm = self._app.dm
dm.abortTransaction(ttid)
dm.releaseData([x[1] for x in transaction.store_dict.itervalues()],
True)
# unlock any object # unlock any object
for oid in transaction.store_dict, transaction.checked_set: for oid in transaction.store_dict, transaction.checked_set:
for oid in oid: for oid in oid:
......
...@@ -211,15 +211,21 @@ class Test(NEOThreadedTest): ...@@ -211,15 +211,21 @@ class Test(NEOThreadedTest):
data_info[key] = 0 data_info[key] = 0
storage.sync() storage.sync()
txn = [transaction.Transaction() for x in xrange(3)] txn = [transaction.Transaction() for x in xrange(4)]
for t in txn: for t in txn:
storage.tpc_begin(t) storage.tpc_begin(t)
storage.store(tid and oid or storage.new_oid(), storage.store(oid if tid else storage.new_oid(),
tid, data, '', t) tid, data, '', t)
tid = None tid = None
data_info[key] = 4
storage.sync()
self.assertEqual(data_info, cluster.storage.getDataLockInfo())
storage.tpc_abort(txn.pop())
for t in txn: for t in txn:
storage.tpc_vote(t) storage.tpc_vote(t)
data_info[key] = 3 storage.sync()
data_info[key] -= 1
self.assertEqual(data_info, cluster.storage.getDataLockInfo()) self.assertEqual(data_info, cluster.storage.getDataLockInfo())
storage.tpc_abort(txn[1]) storage.tpc_abort(txn[1])
......
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