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) =>
AppStateRef impl ->
L.Logger L.Hasura ->
RebuildableAppContext impl ->
RebuildableSchemaCache ->
(RebuildableAppContext impl -> m (RebuildableAppContext impl, RebuildableSchemaCache)) ->
m ()
updateAppStateRef (AppStateRef lock cacheRef metadataVersionGauge) logger !newAppCtx !newSC =
updateAppStateRef appStateRef@(AppStateRef lock cacheRef metadataVersionGauge) logger action =
withMVarMasked lock $ const do
rebuildableAppContext <- liftIO $ readAppContextRef appStateRef
(!newAppCtx, !newSC) <- action rebuildableAppContext
liftIO do
-- update schemacache in IO reference
modifyIORef' cacheRef $ \appState ->