Commit cff279af authored by Julien Muchembled's avatar Julien Muchembled

fixup! storage: fix pruning of data when deleting partial transactions during verification

This fixes a regression in commit 83fe64bf
when ttrans has several rows to the same data_id.
parent a63bf12f
...@@ -562,21 +562,22 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -562,21 +562,22 @@ class MySQLDatabaseManager(DatabaseManager):
getPartition = self._getPartition getPartition = self._getPartition
q = self.query q = self.query
sql = " FROM tobj WHERE tid=%d" % tid sql = " FROM tobj WHERE tid=%d" % tid
data_id_set = {x for x, in q("SELECT data_id" + sql) if x} data_id_list = [x for x, in q("SELECT data_id" + sql) if x]
self.releaseData(data_id_set) self.releaseData(data_id_list)
q("DELETE" + sql) q("DELETE" + sql)
q("""DELETE FROM ttrans WHERE tid = %d""" % tid) q("""DELETE FROM ttrans WHERE tid = %d""" % tid)
q("""DELETE FROM trans WHERE `partition` = %d AND tid = %d""" % q("""DELETE FROM trans WHERE `partition` = %d AND tid = %d""" %
(getPartition(tid), tid)) (getPartition(tid), tid))
# delete from obj using indexes # delete from obj using indexes
data_id_list = set(data_id_list)
for oid in oid_list: for oid in oid_list:
oid = u64(oid) oid = u64(oid)
sql = " FROM obj WHERE `partition`=%d AND oid=%d AND tid=%d" \ sql = " FROM obj WHERE `partition`=%d AND oid=%d AND tid=%d" \
% (getPartition(oid), oid, tid) % (getPartition(oid), oid, tid)
data_id_set.update(*q("SELECT data_id" + sql)) data_id_list.update(*q("SELECT data_id" + sql))
q("DELETE" + sql) q("DELETE" + sql)
data_id_set.discard(None) data_id_list.discard(None)
self._pruneData(data_id_set) self._pruneData(data_id_list)
def deleteObject(self, oid, serial=None): def deleteObject(self, oid, serial=None):
u64 = util.u64 u64 = util.u64
......
...@@ -425,21 +425,22 @@ class SQLiteDatabaseManager(DatabaseManager): ...@@ -425,21 +425,22 @@ class SQLiteDatabaseManager(DatabaseManager):
getPartition = self._getPartition getPartition = self._getPartition
q = self.query q = self.query
sql = " FROM tobj WHERE tid=?" sql = " FROM tobj WHERE tid=?"
data_id_set = {x for x, in q("SELECT data_id" + sql, (tid,)) if x} data_id_list = [x for x, in q("SELECT data_id" + sql, (tid,)) if x]
self.releaseData(data_id_set) self.releaseData(data_id_list)
q("DELETE" + sql, (tid,)) q("DELETE" + sql, (tid,))
q("DELETE FROM ttrans WHERE tid=?", (tid,)) q("DELETE FROM ttrans WHERE tid=?", (tid,))
q("DELETE FROM trans WHERE partition=? AND tid=?", q("DELETE FROM trans WHERE partition=? AND tid=?",
(getPartition(tid), tid)) (getPartition(tid), tid))
# delete from obj using indexes # delete from obj using indexes
data_id_list = set(data_id_list)
for oid in oid_list: for oid in oid_list:
oid = u64(oid) oid = u64(oid)
sql = " FROM obj WHERE partition=? AND oid=? AND tid=?" sql = " FROM obj WHERE partition=? AND oid=? AND tid=?"
args = getPartition(oid), oid, tid args = getPartition(oid), oid, tid
data_id_set.update(*q("SELECT data_id" + sql, args)) data_id_list.update(*q("SELECT data_id" + sql, args))
q("DELETE" + sql, args) q("DELETE" + sql, args)
data_id_set.discard(None) data_id_list.discard(None)
self._pruneData(data_id_set) self._pruneData(data_id_list)
def deleteObject(self, oid, serial=None): def deleteObject(self, oid, serial=None):
oid = util.u64(oid) oid = util.u64(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