[Zodb-checkins] CVS: ZODB3/BDBStorage/tests -
test_autopack.py:1.11.2.4
Jeremy Hylton
jeremy at zope.com
Wed Sep 10 23:29:32 EDT 2003
Update of /cvs-repository/ZODB3/BDBStorage/tests
In directory cvs.zope.org:/tmp/cvs-serv15030/BDBStorage/tests
Modified Files:
Tag: ZODB3-3_2-branch
test_autopack.py
Log Message:
Remove code that existed only to support race conditions tests,
which were removed earlier.
=== ZODB3/BDBStorage/tests/test_autopack.py 1.11.2.3 => 1.11.2.4 ===
--- ZODB3/BDBStorage/tests/test_autopack.py:1.11.2.3 Wed Sep 10 13:28:19 2003
+++ ZODB3/BDBStorage/tests/test_autopack.py Wed Sep 10 22:29:31 2003
@@ -271,133 +271,6 @@
-# Subclass which does ugly things to _dopack so we can actually test the race
-# condition. We need to store a new object in the database between the
-# _mark() call and the _sweep() call.
-class SynchronizedFullStorage(BDBFullStorage):
- # XXX Cut and paste copy from BDBFullStorage, except where indicated
- def _dopack(self, t, gc=True):
- # t is a TimeTime, or time float, convert this to a TimeStamp object,
- # using an algorithm similar to what's used in FileStorage. We know
- # that our transaction ids, a.k.a. revision ids, are timestamps.
- #
- # BAW: should a pack time in the future be a ValueError? We'd have to
- # worry about clock skew, so for now, we just set the pack time to the
- # minimum of t and now.
- packtime = min(t, time.time())
- t0 = TimeStamp(*(time.gmtime(packtime)[:5] + (packtime % 60,)))
- packtid = `t0`
- # Collect all revisions of all objects earlier than the pack time.
- self._lock_acquire()
- try:
- self._withtxn(self._collect_revs, packtid)
- finally:
- self._lock_release()
- # Collect any objects with refcount zero.
- self._lock_acquire()
- try:
- self._withtxn(self._collect_objs)
- finally:
- self._lock_release()
- # If we're not doing a classic pack, we're done.
- if not gc:
- return
- # Do a mark and sweep for garbage collection. Calculate the set of
- # objects reachable from the root. Anything else is a candidate for
- # having all their revisions packed away. The set of reachable
- # objects lives in the _packmark table.
- self._lock_acquire()
- try:
- self._withtxn(self._mark, packtid)
- finally:
- self._lock_release()
- # XXX thread coordination code start
- self.cv.acquire()
- self.cv.notify()
- self.cv.wait()
- # XXX thread coordination code stop
- #
- # Now perform a sweep, using oidqueue to hold all object ids for
- # objects which are not root reachable as of the pack time.
- self._lock_acquire()
- try:
- self._withtxn(self._sweep, packtid)
- finally:
- self._lock_release()
- # Once again, collect any objects with refcount zero due to the mark
- # and sweep garbage collection pass.
- self._lock_acquire()
- try:
- self._withtxn(self._collect_objs)
- finally:
- self._lock_release()
- # XXX thread coordination code start
- self.cv.notify()
- self.cv.release()
- # XXX thread coordination code stop
-
-
-class FullPackThread(threading.Thread):
- def __init__(self, storage):
- threading.Thread.__init__(self)
- self._storage = storage
-
- def run(self):
- self._storage.autopack(time.time(), gc=True)
-
-
-
-# Subclass which does ugly things to _dopack so we can actually test the race
-# condition. We need to storage a new object in the database between the
-# _mark() call and the _sweep() call.
-class SynchronizedMinimalStorage(BDBMinimalStorage):
- # XXX Cut and paste copy from BDBMinimalStorage, except where indicated
- def _dopack(self):
- # Do a mark and sweep for garbage collection. Calculate the set of
- # objects reachable from the root. Anything else is a candidate for
- # having all their revisions packed away. The set of reachable
- # objects lives in the _packmark table.
- self._lock_acquire()
- try:
- self._withtxn(self._mark)
- finally:
- self._lock_release()
- # XXX thread coordination code start
- self.cv.acquire()
- self.cv.notify()
- self.cv.wait()
- # XXX thread coordination code stop
- #
- # Now perform a sweep, using oidqueue to hold all object ids for
- # objects which are not root reachable as of the pack time.
- self._lock_acquire()
- try:
- self._withtxn(self._sweep)
- finally:
- self._lock_release()
- # Once again, collect any objects with refcount zero due to the mark
- # and sweep garbage collection pass.
- self._lock_acquire()
- try:
- self._withtxn(self._collect_objs)
- finally:
- self._lock_release()
- # XXX thread coordination code start
- self.cv.notify()
- self.cv.release()
- # XXX thread coordination code stop
-
-
-class MinimalPackThread(threading.Thread):
- def __init__(self, storage):
- threading.Thread.__init__(self)
- self._storage = storage
-
- def run(self):
- self._storage.pack(time.time(), referencesf)
-
-
-
def test_suite():
suite = unittest.TestSuite()
suite.level = 2
More information about the Zodb-checkins
mailing list