Commit 13a4bef6 authored by Jeremy Hylton's avatar Jeremy Hylton

Add a sleep(1) before each pack() call.

pack() uses a coarse-grain timer to decide which revisions to look at
during a pack.  The tests depend on a pack() called after a commit to
see that committed transaction, but the implementation can't guarantee
that it will.

In particular, pack() converts its time argument to a TimeStamp by
truncating to the nearest second.  If a transaction T1 commits and pack
is called (with the current time as its argument) during the same second,
the pack() will not consider T1.  This was causing intermittent, but
frequent test failures on Windows.

The fix is to add a small delay in the pack test cases to guarantee that
pack(time.time()) will always see the last committed transaction.
parent b94b218f
...@@ -119,6 +119,13 @@ class PackableStorage(PackableStorageBase): ...@@ -119,6 +119,13 @@ class PackableStorage(PackableStorageBase):
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
def checkPackEmptyStorage(self):
self._storage.pack(time.time(), referencesf)
def checkPackTomorrow(self):
self._initroot()
self._storage.pack(time.time() + 10000, referencesf)
def checkPackAllRevisions(self): def checkPackAllRevisions(self):
self._initroot() self._initroot()
eq = self.assertEqual eq = self.assertEqual
...@@ -146,7 +153,9 @@ class PackableStorage(PackableStorageBase): ...@@ -146,7 +153,9 @@ class PackableStorage(PackableStorageBase):
pobj = pickle.loads(data) pobj = pickle.loads(data)
eq(pobj.getoid(), oid) eq(pobj.getoid(), oid)
eq(pobj.value, 3) eq(pobj.value, 3)
# Now pack all transactions # Now pack all transactions; need to sleep a second to make
# sure that the pack time is greater than the last commit time.
time.sleep(1)
self._storage.pack(time.time(), referencesf) self._storage.pack(time.time(), referencesf)
# All revisions of the object should be gone, since there is no # All revisions of the object should be gone, since there is no
# reference from the root object to this object. # reference from the root object to this object.
...@@ -197,6 +206,7 @@ class PackableStorage(PackableStorageBase): ...@@ -197,6 +206,7 @@ class PackableStorage(PackableStorageBase):
eq(pobj.value, 3) eq(pobj.value, 3)
# Now pack just revisions 1 and 2. The object's current revision # Now pack just revisions 1 and 2. The object's current revision
# should stay alive because it's pointed to by the root. # should stay alive because it's pointed to by the root.
time.sleep(1)
self._storage.pack(time.time(), referencesf) self._storage.pack(time.time(), referencesf)
# Make sure the revisions are gone, but that object zero and revision # Make sure the revisions are gone, but that object zero and revision
# 3 are still there and correct # 3 are still there and correct
...@@ -273,6 +283,7 @@ class PackableStorage(PackableStorageBase): ...@@ -273,6 +283,7 @@ class PackableStorage(PackableStorageBase):
# Now pack just revisions 1 and 2 of object1. Object1's current # Now pack just revisions 1 and 2 of object1. Object1's current
# revision should stay alive because it's pointed to by the root, as # revision should stay alive because it's pointed to by the root, as
# should Object2's current revision. # should Object2's current revision.
time.sleep(1)
self._storage.pack(time.time(), referencesf) self._storage.pack(time.time(), referencesf)
# Make sure the revisions are gone, but that object zero, object2, and # Make sure the revisions are gone, but that object zero, object2, and
# revision 3 of object1 are still there and correct. # revision 3 of object1 are still there and correct.
......
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