From: Joey Hess Date: Tue, 19 Oct 2021 17:07:49 +0000 (-0400) Subject: close keys db to possibly work around WSL1 issue X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~79^2~124 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0f38ad9a69f07f6c6dfb164ad87ecfd56036496f;p=git-annex.git close keys db to possibly work around WSL1 issue --- diff --git a/Annex/Link.hs b/Annex/Link.hs index c305b39bd7..878228788d 100644 --- a/Annex/Link.hs +++ b/Annex/Link.hs @@ -203,7 +203,12 @@ restagePointerFile (Restage True) f orig = withTSDelta $ \tsd -> -- updated index file. runner :: Git.Queue.InternalActionRunner Annex 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 realindex <- liftIO $ Git.Index.currentIndexFile r let lock = fromRawFilePath (Git.Index.indexFileLock realindex) diff --git a/Database/Keys.hs b/Database/Keys.hs index 4aeee67bd1..afd6048ada 100644 --- a/Database/Keys.hs +++ b/Database/Keys.hs @@ -37,7 +37,7 @@ import qualified Annex import Annex.LockFile import Annex.Content.PointerFile import Annex.Content.Presence.LowLevel -import Annex.Link +import Annex.Link (Restage(..), maxPointerSz, parseLinkTargetOrPointerLazy) import Utility.InodeCache import Annex.InodeSentinal import Git diff --git a/doc/bugs/WSL_adjusted_braches__58___smudge_fails_with_sqlite_thread_crashed_-_locking_protocol/comment_6_b7a3837fd6af236e9ecf6d5bae077fd0._comment b/doc/bugs/WSL_adjusted_braches__58___smudge_fails_with_sqlite_thread_crashed_-_locking_protocol/comment_6_b7a3837fd6af236e9ecf6d5bae077fd0._comment new file mode 100644 index 0000000000..5f46a0be3c --- /dev/null +++ b/doc/bugs/WSL_adjusted_braches__58___smudge_fails_with_sqlite_thread_crashed_-_locking_protocol/comment_6_b7a3837fd6af236e9ecf6d5bae077fd0._comment @@ -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. +"""]]