Remove Hoogle lock

This commit is contained in:
Michael Snoyman 2020-09-03 16:03:01 +03:00
parent 68fa14a4bb
commit 3d8cd6a115
No known key found for this signature in database
GPG Key ID: 907EAE2F42B52046
3 changed files with 1 additions and 10 deletions

View File

@ -160,7 +160,6 @@ withFoundation appLogFunc appSettings inner = do
\oldMatcher -> getLatestMatcher appHttpManager `catchAny` \e -> do \oldMatcher -> getLatestMatcher appHttpManager `catchAny` \e -> do
runRIO appLogFunc $ RIO.logError $ "Couldn't get Stack matcher: " <> displayShow e runRIO appLogFunc $ RIO.logError $ "Couldn't get Stack matcher: " <> displayShow e
pure oldMatcher pure oldMatcher
appHoogleLock <- newMVar ()
appMirrorStatus <- mkUpdateMirrorStatus appMirrorStatus <- mkUpdateMirrorStatus
hoogleLocker <- newHoogleLocker appLogFunc appHttpManager hoogleLocker <- newHoogleLocker appLogFunc appHttpManager
let appGetHoogleDB = singleRun hoogleLocker let appGetHoogleDB = singleRun hoogleLocker

View File

@ -35,9 +35,6 @@ data App = App
, appStackageDatabase :: !StackageDatabase , appStackageDatabase :: !StackageDatabase
, appLatestStackMatcher :: !(IO (Text -> Maybe Text)) , appLatestStackMatcher :: !(IO (Text -> Maybe Text))
-- ^ Give a pattern, get a URL -- ^ Give a pattern, get a URL
, appHoogleLock :: !(MVar ())
-- ^ Avoid concurrent Hoogle queries, see
-- https://github.com/fpco/stackage-server/issues/172
, appMirrorStatus :: !(IO (Status, WidgetFor App ())) , appMirrorStatus :: !(IO (Status, WidgetFor App ()))
, appGetHoogleDB :: !(SnapName -> IO (Maybe FilePath)) , appGetHoogleDB :: !(SnapName -> IO (Maybe FilePath))
, appGitRev :: !GitRev , appGitRev :: !GitRev

View File

@ -47,9 +47,6 @@ getHoogleR name0 = track "Handler.Hoogle.getHoogleR" do
mdatabasePath <- getHoogleDB name mdatabasePath <- getHoogleDB name
dbPath <- maybe (hoogleDatabaseNotAvailableFor name) return mdatabasePath dbPath <- maybe (hoogleDatabaseNotAvailableFor name) return mdatabasePath
-- Avoid concurrent Hoogle queries, see
-- https://github.com/fpco/stackage-server/issues/172
lock <- appHoogleLock <$> getYesod
urlRender <- getUrlRender urlRender <- getUrlRender
HoogleQueryOutput results mtotalCount <- HoogleQueryOutput results mtotalCount <-
case mquery of case mquery of
@ -64,9 +61,7 @@ getHoogleR name0 = track "Handler.Hoogle.getHoogleR" do
, hqiExact = exact , hqiExact = exact
} }
liftIO $ withMVar lock liftIO $ Hoogle.withDatabase dbPath
$ const
$ Hoogle.withDatabase dbPath
-- NB! I got a segfault when I didn't force with $! -- NB! I got a segfault when I didn't force with $!
$ \db -> return $! runHoogleQuery urlRender name db input $ \db -> return $! runHoogleQuery urlRender name db input
Nothing -> return $ HoogleQueryOutput [] Nothing Nothing -> return $ HoogleQueryOutput [] Nothing