Skip to content

Commit ab01084

Browse files
committed
dont wrap action with hiedb retry on the writer side, give hiedb retry wrapper to action instead
1 parent 433ee9a commit ab01084

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ runWithDb logger fp k = do
253253
_ <- garbageCollectTypeNames db
254254
forever $ do
255255
k <- atomically $ readTQueue chan
256-
retryOnSqliteBusy logger db oneSecond oneMillisecond maxRetryCount rng k
256+
k (retryOnSqliteBusy logger db oneSecond oneMillisecond maxRetryCount rng)
257257
`Safe.catch` \e@SQLError{} -> do
258258
logDebug logger $ T.pack $ "SQLite error in worker, ignoring: " ++ show e
259259
`Safe.catchAny` \e -> do

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ indexHieFile se mod_summary srcPath !hash hf = do
521521
-- hiedb doesn't use the Haskell src, so we clear it to avoid unnecessarily keeping it around
522522
let !hf' = hf{hie_hs_src = mempty}
523523
modifyTVar' indexPending $ HashMap.insert srcPath hash
524-
writeTQueue indexQueue $ \db -> do
524+
writeTQueue indexQueue $ \withHieDb -> do
525525
-- We are now in the worker thread
526526
-- Check if a newer index of this file has been scheduled, and if so skip this one
527527
newerScheduled <- atomically $ do
@@ -532,7 +532,7 @@ indexHieFile se mod_summary srcPath !hash hf = do
532532
Just pendingHash -> pendingHash /= hash
533533
unless newerScheduled $ do
534534
pre optProgressStyle
535-
addRefsFromLoaded db targetPath (RealFile $ fromNormalizedFilePath srcPath) hash hf'
535+
withHieDb (\db -> HieDb.addRefsFromLoaded db targetPath (HieDb.RealFile $ fromNormalizedFilePath srcPath) hash hf')
536536
post
537537
where
538538
mod_location = ms_location mod_summary

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ setSomethingModified state keys reason = do
294294
fail "setSomethingModified can't be called on this type of VFSHandle"
295295
-- Update database to remove any files that might have been renamed/deleted
296296
atomically $ do
297-
writeTQueue (indexQueue $ hiedbWriter $ shakeExtras state) deleteMissingRealFiles
297+
writeTQueue (indexQueue $ hiedbWriter $ shakeExtras state) (\withHieDb -> withHieDb deleteMissingRealFiles)
298298
modifyTVar' (dirtyKeys $ shakeExtras state) $ \x ->
299299
foldl' (flip HSet.insert) x keys
300300
void $ restartShakeSession (shakeExtras state) reason []

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ data HieDbWriter
183183
}
184184

185185
-- | Actions to queue up on the index worker thread
186-
type IndexQueue = TQueue (HieDb -> IO ())
186+
-- The inner `(HieDb -> IO ()) -> IO ()` wraps `HieDb -> IO ()`
187+
-- with (currently) retry functionality
188+
type IndexQueue = TQueue (((HieDb -> IO ()) -> IO ()) -> IO ())
187189

188190
-- | Intended to represent HieDb calls wrapped with (currently) retry
189191
-- functionality

0 commit comments

Comments
 (0)