remove stale live changes from reposize database
Reorganized the reposize database directory, and split up a column. checkStaleSizeChanges needs to run before needLiveUpdate, otherwise the process won't be holding a lock on its pid file, and another process could go in and expire the live update it records. It just so happens that they do get called in the correct order, since checking balanced preferred content calls getLiveRepoSizes before needLiveUpdate. The 1 minute delay between checks is arbitrary, but will avoid excess work. The downside of it is that, if a process is dropping a file and gets interrupted, for 1 minute another process can expect a repository will soon be smaller than it is. And so a process might send data to a repository when a file is not really going to be dropped from it. But note that can already happen if a drop takes some time in eg locking and then fails. So it seems possible that live updates should only be allowed to increase, rather than decrease the size of a repository.
This commit is contained in:
parent
278adbb726
commit
f89a1b8216
7 changed files with 199 additions and 83 deletions
|
@ -17,6 +17,7 @@ import qualified Annex
|
|||
import Annex.Branch (UnmergedBranches(..), getBranch)
|
||||
import qualified Database.RepoSize as Db
|
||||
import Annex.Journal
|
||||
import Annex.RepoSize.LiveUpdate
|
||||
import Logs
|
||||
import Logs.Location
|
||||
import Logs.UUID
|
||||
|
@ -55,6 +56,7 @@ getLiveRepoSizes quiet = do
|
|||
where
|
||||
go sizemap = do
|
||||
h <- Db.getRepoSizeHandle
|
||||
checkStaleSizeChanges h
|
||||
liveoffsets <- liftIO $ Db.liveRepoOffsets h
|
||||
let calc u (RepoSize size, SizeOffset startoffset) =
|
||||
case M.lookup u liveoffsets of
|
||||
|
@ -86,12 +88,12 @@ calcRepoSizes quiet rsv = go `onException` failed
|
|||
calculatefromscratch h = do
|
||||
unless quiet $
|
||||
showSideAction "calculating repository sizes"
|
||||
(sizemap, branchsha) <- calcBranchRepoSizes
|
||||
liftIO $ Db.setRepoSizes h sizemap branchsha
|
||||
calcJournalledRepoSizes h sizemap branchsha
|
||||
use h =<< calcBranchRepoSizes
|
||||
|
||||
incrementalupdate h oldsizemap oldbranchsha currbranchsha = do
|
||||
(sizemap, branchsha) <- diffBranchRepoSizes quiet oldsizemap oldbranchsha currbranchsha
|
||||
incrementalupdate h oldsizemap oldbranchsha currbranchsha =
|
||||
use h =<< diffBranchRepoSizes quiet oldsizemap oldbranchsha currbranchsha
|
||||
|
||||
use h (sizemap, branchsha) = do
|
||||
liftIO $ Db.setRepoSizes h sizemap branchsha
|
||||
calcJournalledRepoSizes h sizemap branchsha
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue