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
|
@ -8,7 +8,15 @@
|
|||
module Database.RepoSize.Handle where
|
||||
|
||||
import qualified Database.Handle as H
|
||||
import Utility.LockPool (LockHandle)
|
||||
|
||||
-- Contains Nothing if the database was not able to be opened due to
|
||||
-- permissions.
|
||||
newtype RepoSizeHandle = RepoSizeHandle (Maybe H.DbHandle)
|
||||
import Control.Concurrent
|
||||
import Data.Time.Clock.POSIX
|
||||
|
||||
data RepoSizeHandle = RepoSizeHandle
|
||||
(Maybe H.DbHandle)
|
||||
-- ^ Nothing if the database was not able to be opened due to
|
||||
-- permissions.
|
||||
(MVar (Maybe (LockHandle, POSIXTime)))
|
||||
-- ^ Live update lock and time of last check for stale live
|
||||
-- updates.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue