remotefilelog: commit the dirty shared mutable packs on transaction abort

Summary:
Since the shared mutable packs contain fetched data from the network, not
commiting them means that we would need to redownload the data again. Let's
persist them on disk instead to avoid having to redownload them.

Reviewed By: quark-zju

Differential Revision: D17115796

fbshipit-source-id: 3e213461c7a864156ee4c6c68e6a042294883f9d
This commit is contained in:
Xavier Deguillard 2019-08-30 16:12:13 -07:00 committed by Facebook Github Bot
parent 4b28370d5e
commit 0f125b4073
2 changed files with 16 additions and 9 deletions

View File

@ -529,10 +529,8 @@ class remotefileslog(filelog.fileslog):
def getmutablesharedpacks(self):
return self._mutablesharedpacks.getmutablepack()
def commitpending(self):
"""Used in alternative filelog implementations to commit pending
additions."""
self._mutablelocalpacks.commit()
def commitsharedpacks(self):
"""Persist the dirty data written to the shared packs."""
dpackpath, hpackpath = self._mutablesharedpacks.commit()
self.repo.fileservice.updatecache(dpackpath, hpackpath)
@ -540,12 +538,17 @@ class remotefileslog(filelog.fileslog):
self.contentstore.markforrefresh()
self.metadatastore.markforrefresh()
def commitpending(self):
"""Used in alternative filelog implementations to commit pending
additions."""
self._mutablelocalpacks.commit()
self.commitsharedpacks()
def abortpending(self):
"""Used in alternative filelog implementations to throw out pending
additions."""
self._mutablelocalpacks.abort()
# XXX: Maybe we actually want to commit these
self._mutablesharedpacks.abort()
self.commitsharedpacks()
def makeunionstores(self):
"""Union stores iterate the other stores and return the first result."""

View File

@ -894,16 +894,20 @@ class basetreemanifestlog(object):
)
return node
def commitpending(self):
self._mutablelocalpacks.commit()
def commitsharedpacks(self):
"""Persist the dirty trees written to the shared packs."""
self._mutablesharedpacks.commit()
self.datastore.markforrefresh()
self.historystore.markforrefresh()
def commitpending(self):
self._mutablelocalpacks.commit()
self.commitsharedpacks()
def abortpending(self):
self._mutablelocalpacks.abort()
self._mutablesharedpacks.abort()
self.commitsharedpacks()
def __nonzero__(self):
return True