From 93025dd59ff5da630e7eb73041271a3d35cfe0c7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 7 Mar 2019 13:32:33 -0400 Subject: [PATCH] add missing locking of ContentIdentifier database when writing This is not super efficient; it would be better to lock the database once and build up a queue of changes and flush once. But, storeExportWithContentIdentifier is likely going to be the really expensive part, so let's do the simple thing and only optimise later if needed. --- Remote/Helper/ExportImport.hs | 5 ++++- doc/todo/import_tree.mdwn | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Remote/Helper/ExportImport.hs b/Remote/Helper/ExportImport.hs index 8cfcb9cc87..f7faa2c513 100644 --- a/Remote/Helper/ExportImport.hs +++ b/Remote/Helper/ExportImport.hs @@ -19,6 +19,7 @@ import qualified Database.Export as Export import qualified Database.ContentIdentifier as ContentIdentifier import Annex.Export import Annex.Import +import Annex.LockFile import Config import Git.Types (fromRef) import Logs.Export @@ -155,7 +156,9 @@ adjustExportImport r = case M.lookup "exporttree" (config r) of storeExportWithContentIdentifier (importActions r') f k loc knowncids p >>= \case Nothing -> return False Just newcid -> do - liftIO $ ContentIdentifier.recordContentIdentifier db (uuid r') newcid k + withExclusiveLock gitAnnexContentIdentifierLock $ do + liftIO $ ContentIdentifier.recordContentIdentifier db (uuid r') newcid k + liftIO $ ContentIdentifier.flushDbQueue db recordContentIdentifier (uuid r') newcid k return True , removeExport = \k loc -> do diff --git a/doc/todo/import_tree.mdwn b/doc/todo/import_tree.mdwn index 26cff66c54..03aaaedf1a 100644 --- a/doc/todo/import_tree.mdwn +++ b/doc/todo/import_tree.mdwn @@ -15,9 +15,6 @@ this. Note that updating the db needs to write lock it. -* Remote.Helper.ExportImport calls recordContentIdentifier on a database - that is not write locked. - * Need to support annex-tracking-branch configuration, which documentation says makes git-annex sync and assistant do imports.