Commit 6f71311c authored by Barry Warsaw's avatar Barry Warsaw

_dopack(): We must make sure that we close the cursor on the

self._metadata table after we're done with it, otherwise the test
suite hangs.
parent b65c6a67
...@@ -18,7 +18,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support ...@@ -18,7 +18,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning. undo or versioning.
""" """
__version__ = '$Revision: 1.39 $'.split()[-2:][0] __version__ = '$Revision: 1.40 $'.split()[-2:][0]
import sys import sys
import struct import struct
...@@ -1152,35 +1152,40 @@ class Full(BerkeleyBase, ConflictResolvingStorage): ...@@ -1152,35 +1152,40 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# values which are a list of revisions (oid+tid) that can be packed. # values which are a list of revisions (oid+tid) that can be packed.
packablerevs = {} packablerevs = {}
c = self._metadata.cursor() c = self._metadata.cursor()
# BAW: can two threads be packing at the same time? If so, we need to try:
# handle that. If not, we should enforce that with a pack-lock. # BAW: can two threads be packing at the same time? If so, we
for oid in self._serials.keys(): # need to handle that. If not, we should enforce that with a
try: # pack-lock.
rec = c.set_range(oid+packtid) for oid in self._serials.keys():
# The one just before this should be the largest record less try:
# than or equal to the key, i.e. the object revision just rec = c.set_range(oid+packtid)
# before the given pack time. # The one just before this should be the largest record
rec = c.prev() # less than or equal to the key, i.e. the object revision
except db.DBNotFoundError: # just before the given pack time.
# Perhaps the last record in the database is the last one rec = c.prev()
# containing this oid? except db.DBNotFoundError:
rec = c.last() # Perhaps the last record in the database is the last one
# Now move backwards in time to look at all the revisions of this # containing this oid?
# object. All but the current one are packable, unless the object rec = c.last()
# isn't reachable from the root, in which case, all its revisions # Now move backwards in time to look at all the revisions of
# are packable. # this object. All but the current one are packable, unless
while rec: # the object isn't reachable from the root, in which case, all
key, data = rec # its revisions are packable.
rec = c.prev() while rec:
# Make sure we're still looking at revisions for this object key, data = rec
if oid <> key[:8]: rec = c.prev()
break # Make sure we're still looking at revisions for this
if not reachables.has_key(oid): # object
packablerevs.setdefault(oid, []).append(key) if oid <> key[:8]:
# Otherwise, if this isn't the current revision for this break
# object, then it's packable. if not reachables.has_key(oid):
elif self._serials[oid] <> key[8:]: packablerevs.setdefault(oid, []).append(key)
packablerevs.setdefault(oid, []).append(key) # Otherwise, if this isn't the current revision for this
# object, then it's packable.
elif self._serials[oid] <> key[8:]:
packablerevs.setdefault(oid, []).append(key)
finally:
c.close()
# We now have all the packable revisions we're going to handle. For # We now have all the packable revisions we're going to handle. For
# each object with revisions that we're going to pack away, acquire # each object with revisions that we're going to pack away, acquire
# the storage lock so we can do that without fear of trampling by # the storage lock so we can do that without fear of trampling by
......
...@@ -18,7 +18,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support ...@@ -18,7 +18,7 @@ See Minimal.py for an implementation of Berkeley storage that does not support
undo or versioning. undo or versioning.
""" """
__version__ = '$Revision: 1.39 $'.split()[-2:][0] __version__ = '$Revision: 1.40 $'.split()[-2:][0]
import sys import sys
import struct import struct
...@@ -1152,35 +1152,40 @@ class Full(BerkeleyBase, ConflictResolvingStorage): ...@@ -1152,35 +1152,40 @@ class Full(BerkeleyBase, ConflictResolvingStorage):
# values which are a list of revisions (oid+tid) that can be packed. # values which are a list of revisions (oid+tid) that can be packed.
packablerevs = {} packablerevs = {}
c = self._metadata.cursor() c = self._metadata.cursor()
# BAW: can two threads be packing at the same time? If so, we need to try:
# handle that. If not, we should enforce that with a pack-lock. # BAW: can two threads be packing at the same time? If so, we
for oid in self._serials.keys(): # need to handle that. If not, we should enforce that with a
try: # pack-lock.
rec = c.set_range(oid+packtid) for oid in self._serials.keys():
# The one just before this should be the largest record less try:
# than or equal to the key, i.e. the object revision just rec = c.set_range(oid+packtid)
# before the given pack time. # The one just before this should be the largest record
rec = c.prev() # less than or equal to the key, i.e. the object revision
except db.DBNotFoundError: # just before the given pack time.
# Perhaps the last record in the database is the last one rec = c.prev()
# containing this oid? except db.DBNotFoundError:
rec = c.last() # Perhaps the last record in the database is the last one
# Now move backwards in time to look at all the revisions of this # containing this oid?
# object. All but the current one are packable, unless the object rec = c.last()
# isn't reachable from the root, in which case, all its revisions # Now move backwards in time to look at all the revisions of
# are packable. # this object. All but the current one are packable, unless
while rec: # the object isn't reachable from the root, in which case, all
key, data = rec # its revisions are packable.
rec = c.prev() while rec:
# Make sure we're still looking at revisions for this object key, data = rec
if oid <> key[:8]: rec = c.prev()
break # Make sure we're still looking at revisions for this
if not reachables.has_key(oid): # object
packablerevs.setdefault(oid, []).append(key) if oid <> key[:8]:
# Otherwise, if this isn't the current revision for this break
# object, then it's packable. if not reachables.has_key(oid):
elif self._serials[oid] <> key[8:]: packablerevs.setdefault(oid, []).append(key)
packablerevs.setdefault(oid, []).append(key) # Otherwise, if this isn't the current revision for this
# object, then it's packable.
elif self._serials[oid] <> key[8:]:
packablerevs.setdefault(oid, []).append(key)
finally:
c.close()
# We now have all the packable revisions we're going to handle. For # We now have all the packable revisions we're going to handle. For
# each object with revisions that we're going to pack away, acquire # each object with revisions that we're going to pack away, acquire
# the storage lock so we can do that without fear of trampling by # the storage lock so we can do that without fear of trampling by
......
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