server: fix race condition in reloadAppContext

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9788
GitOrigin-RevId: c6b9441e4f4e12fea6ad4e5b336f3231fc4494d2
This commit is contained in:
Puru Gupta 2023-07-07 04:29:49 +05:30 committed by hasura-bot
parent d61d523f77
commit 1d8d934157

View File

@ -276,11 +276,12 @@ updateAppStateRef ::
(MonadIO m, MonadBaseControl IO m) => (MonadIO m, MonadBaseControl IO m) =>
AppStateRef impl -> AppStateRef impl ->
L.Logger L.Hasura -> L.Logger L.Hasura ->
RebuildableAppContext impl -> (RebuildableAppContext impl -> m (RebuildableAppContext impl, RebuildableSchemaCache)) ->
RebuildableSchemaCache ->
m () m ()
updateAppStateRef (AppStateRef lock cacheRef metadataVersionGauge) logger !newAppCtx !newSC = updateAppStateRef appStateRef@(AppStateRef lock cacheRef metadataVersionGauge) logger action =
withMVarMasked lock $ const do withMVarMasked lock $ const do
rebuildableAppContext <- liftIO $ readAppContextRef appStateRef
(!newAppCtx, !newSC) <- action rebuildableAppContext
liftIO do liftIO do
-- update schemacache in IO reference -- update schemacache in IO reference
modifyIORef' cacheRef $ \appState -> modifyIORef' cacheRef $ \appState ->