[Checkins] SVN: zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py Added a batch_size option, defaulting to 10000. We were running out
Jim Fulton
jim at zope.com
Tue May 26 11:02:49 EDT 2009
Log message for revision 100412:
Added a batch_size option, defaulting to 10000. We were running out
of memory packing large databases because of large trasnaction sizes.
This is an option mainly for testability. :)
Changed:
U zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py
-=-
Modified: zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py
===================================================================
--- zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py 2009-05-26 14:42:40 UTC (rev 100411)
+++ zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py 2009-05-26 15:02:49 UTC (rev 100412)
@@ -31,7 +31,7 @@
logger = logging.getLogger(__name__)
-def gc(conf, days=1, conf2=None):
+def gc(conf, days=1, conf2=None, batch_size=10000):
db1 = ZODB.config.databaseFromFile(open(conf))
if conf2 is None:
db2 = db1
@@ -134,6 +134,12 @@
p, s = storage.load(oid, '')
storage.deleteObject(oid, s, t)
nd += 1
+ if (nd % batch_size) == 0:
+ storage.tpc_vote(t)
+ storage.tpc_finish(t)
+ t.commit()
+ t = transaction.begin()
+
logger.info("Removed %s objects from %s", nd, name)
if nd:
storage.tpc_vote(t)
More information about the Checkins
mailing list