hg_import_helper close the old repo object before unreferencing it

Summary:
In some cases we decide to reopen the repo speculatively to see if a
missing cache invalidation was preventing us from importing some data.  We're
seeing some leaky behavior and so we're now trying to use the `close` method to
see if that helps clean some things up.

Reviewed By: strager

Differential Revision: D8323584

fbshipit-source-id: 7b022edd58f4ac555b508c1e181677ddc7bc60a4
This commit is contained in:
Wez Furlong 2018-06-07 17:40:33 -07:00 committed by Facebook Github Bot
parent e97a82685d
commit c2aa83a8a7

View File

@ -228,6 +228,13 @@ class HgServer(object):
repo = mercurial.hg.repository(repo_ui, self.repo_path)
return repo.unfiltered()
def _reopen_repo(self):
# Close the current repo and make a new one.
# We use this to deal with invalidation related errors that are
# more likely to bubble to the surface with our long lived use case.
self.repo.close()
self.repo = self._open_repo()
def serve(self):
try:
self.initialize()
@ -446,7 +453,7 @@ class HgServer(object):
# These errors come from the server-side; there doesn't seem to be
# a good way to force the server to re-read the data other than
# recreating our repo object.
self.repo = self._open_repo()
self._reopen_repo()
self._fetch_tree_impl(path, manifest_node)
def _fetch_tree_impl(self, path, manifest_node):
@ -592,7 +599,7 @@ class HgServer(object):
# Completely re-initialize our repo object and try again, in hopes
# that this will make the server return data correctly when we
# retry.
self.repo = self._open_repo()
self._reopen_repo()
fctx = self.repo.filectx(path, fileid=rev_hash)
return fctx.data()