close keys db to possibly work around WSL1 issue
authorJoey Hess <joeyh@joeyh.name>
Tue, 19 Oct 2021 17:07:49 +0000 (13:07 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 19 Oct 2021 17:07:49 +0000 (13:07 -0400)
Annex/Link.hs
Database/Keys.hs
doc/bugs/WSL_adjusted_braches__58___smudge_fails_with_sqlite_thread_crashed_-_locking_protocol/comment_6_b7a3837fd6af236e9ecf6d5bae077fd0._comment [new file with mode: 0644]

index c305b39bd7113f6f2ea82ddce87bee4b36398742..878228788df195657ba3a8eac7a98e1e87b4ce03 100644 (file)
@@ -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)
index 4aeee67bd1c3a2cb773037f7262e78fd7fcba29e..afd6048adaff6bb96c18d2d1b3d166d2aa6b8137 100644 (file)
@@ -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 (file)
index 0000000..5f46a0b
--- /dev/null
@@ -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.
+"""]]