[Neo-report] r2100 gregory - in /trunk/neo/storage: database/ handlers/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu May 13 14:03:16 CEST 2010
Author: gregory
Date: Thu May 13 14:03:15 2010
New Revision: 2100
Log:
Drop unassigned partitions in one database query.
Modified:
trunk/neo/storage/database/manager.py
trunk/neo/storage/database/mysqldb.py
trunk/neo/storage/handlers/initialization.py
Modified: trunk/neo/storage/database/manager.py
==============================================================================
--- trunk/neo/storage/database/manager.py [iso-8859-1] (original)
+++ trunk/neo/storage/database/manager.py [iso-8859-1] Thu May 13 14:03:15 2010
@@ -216,10 +216,8 @@
thrown away."""
raise NotImplementedError
- def dropForeignPartitions(self, num_partitions, offset):
- """ Drop objects and transactions assigned to a partition table,
- this should be called only during storage initialization, to clear
- existing data that could be stored by a previous cluster life """
+ def dropPartitions(self, num_partitions, offset_list):
+ """ Drop any data of non-assigned partitions for a given UUID """
raise NotImplementedError('this method must be overriden')
def dropUnfinishedData(self):
Modified: trunk/neo/storage/database/mysqldb.py
==============================================================================
--- trunk/neo/storage/database/mysqldb.py [iso-8859-1] (original)
+++ trunk/neo/storage/database/mysqldb.py [iso-8859-1] Thu May 13 14:03:15 2010
@@ -394,14 +394,16 @@
def setPartitionTable(self, ptid, cell_list):
self.doSetPartitionTable(ptid, cell_list, True)
- def dropPartition(self, num_partitions, offset):
- q = self.query
- self.begin()
- try:
- q("""DELETE FROM obj WHERE MOD(oid, %d) = %d""" %
- (num_partitions, offset))
- q("""DELETE FROM trans WHERE MOD(tid, %d) = %d""" %
- (num_partitions, offset))
+ def dropPartitions(self, num_partitions, offset_list):
+ q = self.query
+ e = self.escape
+ offset_list = ', '.join((str(i) for i in offset_list))
+ self.begin()
+ try:
+ q("""DELETE FROM obj WHERE MOD(oid, %d) IN (%s)""" %
+ (num_partitions, offset_list))
+ q("""DELETE FROM trans WHERE MOD(tid, %d) IN (%s)""" %
+ (num_partitions, offset_list))
except:
self.rollback()
raise
Modified: trunk/neo/storage/handlers/initialization.py
==============================================================================
--- trunk/neo/storage/handlers/initialization.py [iso-8859-1] (original)
+++ trunk/neo/storage/handlers/initialization.py [iso-8859-1] Thu May 13 14:03:15 2010
@@ -44,16 +44,18 @@
self.app.pt.log()
# Install the partition table into the database for persistency.
cell_list = []
- for offset in xrange(app.pt.getPartitions()):
- assigned_to_me = False
+ num_partitions = app.pt.getPartitions()
+ assigned_set = set()
+ for offset in xrange(num_partitions):
for cell in pt.getCellList(offset):
cell_list.append((offset, cell.getUUID(), cell.getState()))
if cell.getUUID() == app.uuid:
- assigned_to_me = True
- if not assigned_to_me:
- logging.debug('drop data for partition %d' % offset)
- # not for me, delete objects database
- app.dm.dropPartition(app.pt.getPartitions(), offset)
+ assigned_set.add(offset)
+ # delete objects database
+ unassigned_set = list(set(xrange(num_partitions)) - assigned_set)
+ if unassigned_set:
+ logging.debug('drop data for partitions %r' % unassigned_set)
+ app.dm.dropPartitions(num_partitions, unassigned_set)
app.dm.setPartitionTable(ptid, cell_list)
self.app.has_partition_table = True
More information about the Neo-report
mailing list