close keys db to possibly work around WSL1 issue

This commit is contained in:
Joey Hess 2021-10-19 13:07:49 -04:00
parent 67a67d740b
commit 0f38ad9a69
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 32 additions and 2 deletions

View file

@ -203,7 +203,12 @@ restagePointerFile (Restage True) f orig = withTSDelta $ \tsd ->
-- updated index file. -- updated index file.
runner :: Git.Queue.InternalActionRunner Annex runner :: Git.Queue.InternalActionRunner Annex
runner = Git.Queue.InternalActionRunner "restagePointerFile" $ \r l -> do runner = Git.Queue.InternalActionRunner "restagePointerFile" $ \r l -> do
liftIO . Database.Keys.Handle.flushDbQueue -- Flush any queued changes to the keys database, so they
-- are visible to child processes.
-- The database is closed because that may improve behavior
-- when run in Windows's WSL1, which has issues with
-- multiple writers to SQL databases.
liftIO . Database.Keys.Handle.closeDbHandle
=<< Annex.getRead Annex.keysdbhandle =<< Annex.getRead Annex.keysdbhandle
realindex <- liftIO $ Git.Index.currentIndexFile r realindex <- liftIO $ Git.Index.currentIndexFile r
let lock = fromRawFilePath (Git.Index.indexFileLock realindex) let lock = fromRawFilePath (Git.Index.indexFileLock realindex)

View file

@ -37,7 +37,7 @@ import qualified Annex
import Annex.LockFile import Annex.LockFile
import Annex.Content.PointerFile import Annex.Content.PointerFile
import Annex.Content.Presence.LowLevel import Annex.Content.Presence.LowLevel
import Annex.Link import Annex.Link (Restage(..), maxPointerSz, parseLinkTargetOrPointerLazy)
import Utility.InodeCache import Utility.InodeCache
import Annex.InodeSentinal import Annex.InodeSentinal
import Git import Git

View file

@ -0,0 +1,25 @@
[[!comment format=mdwn
username="joey"
subject="""comment 6"""
date="2021-10-19T16:44:13Z"
content="""
@asakurareiko it makes sense it would fail that way with WAL disabled,
since the sqlite database cannot support multiple writers then. And
there are probably several situations where multiple git-annex processes
end up using the database, even when you are only running a single
git-annex command at a time.
> Without this patch other than adjusted branches, unlocked files generally do
> work in WSL1. Sqlite error may occur at the end of commands such as `git annex get/drop`
Sounds like `restagePointerFile`, which tends to run at the
end of such an operation to handle all the files that have been updated.
That runs `git update-index`, which then runs `git-annex smudge`.
So both the parent and child git-annex process can have the database open
for write, which WAL mode normally supports, but something in WSL prevents
it from working right.
Following this theory, I've made `restagePointerFile` close the database
first. Perhaps that will avoid the problem, at least in those cases. Your
testing is appreciated.
"""]]