[MERGE][bug #153786] Partial fix for retrying if a pack file disappears
Martin Pool
mbp at canonical.com
Tue Oct 28 07:25:11 GMT 2008
Martin Pool has voted tweak.
Status is now: Conditionally approved
Comment:
Thanks for fixing this.
I wonder if we should do something to prevent it looping indefinitely
while
retrying, but that's probably unlikely and yagni; we can deal with it if
it
arises.
The implementation looks correct and nicely tested.
=== modified file 'NEWS'
--- NEWS 2008-10-21 20:49:54 +0000
+++ NEWS 2008-10-23 21:06:43 +0000
@@ -44,6 +44,11 @@
could only happen if ``bzr reconcile`` decided that the parent
ordering was incorrect in the file graph. (John Arbash Meinel)
+ * The index logic is now able to reload the list of pack files if
and
+ index ends up disappearing. We still don't reload if the pack
data
+ itself goes missing after checking the index.
+ (John Arbash Meinel, #153786)
+
DOCUMENTATION:
To make it more clear which bug this is maybe add
This fixes where operations on a repository transiently fail with
'file not found'
when another process is writing to that repository.
or something similar.
API CHANGES:
=== modified file 'bzrlib/index.py'
--- bzrlib/index.py 2008-09-21 14:48:37 +0000
+++ bzrlib/index.py 2008-10-23 20:53:50 +0000
@@ -27,6 +27,7 @@
from bisect import bisect_right
from cStringIO import StringIO
import re
+import sys
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
@@ -1106,12 +1107,16 @@
in the index list.
"""
- def __init__(self, indices):
+ def __init__(self, indices, reload_func=None):
"""Create a CombinedGraphIndex backed by indices.
:param indices: An ordered list of indices to query for data.
+ :param reload_func: A function to call if we find we are
missing an
+ index. Should have the form reload_func() => True/False to
indicate
+ if reloading actually changed anything.
It wasn't clear to me from this description that 'changed anything'
means 'we
have a chance to now find the indexes'. I thought maybe you meant if it
changed some cached state.
+ def _reload_or_raise(self):
+ """We just got a NoSuchFile exception.
+
+ Try to reload the indices, if it fails, just raise the current
+ exception.
+ """
+ if self._reload_func is None:
+ raise
+ exc_type, exc_value, exc_traceback = sys.exc_info()
+ if not self._reload_func():
+ # We tried to reload, but nothing changed, so we fail
anyway
+ raise exc_type, exc_value, exc_traceback
I would have put a guarded mutter statement here.
--
Martin
For details, see:
http://bundlebuggy.aaronbentley.com/project/bzr/request/%3C4900E912.3030502%40arbash-meinel.com%3E
Project: Bazaar
More information about the bazaar
mailing list