fix(jobs): flush only partially for reliability
This commit is contained in:
parent
fcce16d838
commit
59c7c17665
@ -498,9 +498,12 @@ handleJobs' wNum = C.mapM_ $ \jctl -> hoist delimitInternalState . withJobWorker
|
|||||||
handleCmd JobCtlTest = $logDebugS logIdent "JobCtlTest"
|
handleCmd JobCtlTest = $logDebugS logIdent "JobCtlTest"
|
||||||
handleCmd JobCtlFlush = do
|
handleCmd JobCtlFlush = do
|
||||||
$logDebugS logIdent "JobCtlFlush..."
|
$logDebugS logIdent "JobCtlFlush..."
|
||||||
|
maxFlush <- getsYesod $ view _appJobMaxFlush
|
||||||
|
let selectOpts = [ Asc QueuedJobCreationTime ]
|
||||||
|
& maybe id (\maxCount -> (:) (LimitTo $ fromIntegral maxCount)) maxFlush
|
||||||
heldLocks <- asks jobHeldLocks >>= readTVarIO
|
heldLocks <- asks jobHeldLocks >>= readTVarIO
|
||||||
void . lift . runDB . runConduit
|
void . lift . runDB . runConduit
|
||||||
$ selectKeys [ QueuedJobId /<-. Set.toList heldLocks ] [ Asc QueuedJobCreationTime ]
|
$ selectKeys [ QueuedJobId /<-. Set.toList heldLocks ] selectOpts
|
||||||
.| C.mapM_ (\j -> lift $ runReaderT (writeJobCtl $ JobCtlPerform j) =<< getYesod)
|
.| C.mapM_ (\j -> lift $ runReaderT (writeJobCtl $ JobCtlPerform j) =<< getYesod)
|
||||||
lFlushTVar <- asks jobLastFlush
|
lFlushTVar <- asks jobLastFlush
|
||||||
atomically . modifyTVar' lFlushTVar . max . Just =<< liftIO getCurrentTime
|
atomically . modifyTVar' lFlushTVar . max . Just =<< liftIO getCurrentTime
|
||||||
|
|||||||
@ -179,7 +179,7 @@ determineCrontab = execWriterT $ do
|
|||||||
|
|
||||||
when (isn't _JobsOffload appJobMode) $ do
|
when (isn't _JobsOffload appJobMode) $ do
|
||||||
case appJobFlushInterval of
|
case appJobFlushInterval of
|
||||||
Just interval -> tell $ HashMap.singleton
|
Just interval | maybe True (> 0) appJobMaxFlush -> tell $ HashMap.singleton
|
||||||
JobCtlFlush
|
JobCtlFlush
|
||||||
Cron
|
Cron
|
||||||
{ cronInitial = CronAsap
|
{ cronInitial = CronAsap
|
||||||
@ -187,7 +187,7 @@ determineCrontab = execWriterT $ do
|
|||||||
, cronRateLimit = interval
|
, cronRateLimit = interval
|
||||||
, cronNotAfter = Right CronNotScheduled
|
, cronNotAfter = Right CronNotScheduled
|
||||||
}
|
}
|
||||||
Nothing -> return ()
|
_other -> return ()
|
||||||
|
|
||||||
oldestInvitationMUTC <- lift $ preview (_head . _entityVal . _invitationExpiresAt . _Just) <$> selectList [InvitationExpiresAt !=. Nothing] [Asc InvitationExpiresAt, LimitTo 1]
|
oldestInvitationMUTC <- lift $ preview (_head . _entityVal . _invitationExpiresAt . _Just) <$> selectList [InvitationExpiresAt !=. Nothing] [Asc InvitationExpiresAt, LimitTo 1]
|
||||||
whenIsJust oldestInvitationMUTC $ \oldestInvUTC -> tell $ HashMap.singleton
|
whenIsJust oldestInvitationMUTC $ \oldestInvUTC -> tell $ HashMap.singleton
|
||||||
|
|||||||
@ -94,6 +94,6 @@ healthReportStatus = \case
|
|||||||
HealthWidgetMemcached (Just False) -> HealthFailure -- TODO: investigate this failure mode; do we just handle it gracefully?
|
HealthWidgetMemcached (Just False) -> HealthFailure -- TODO: investigate this failure mode; do we just handle it gracefully?
|
||||||
HealthActiveJobExecutors (Just prop )
|
HealthActiveJobExecutors (Just prop )
|
||||||
| prop <= 0 -> HealthFailure
|
| prop <= 0 -> HealthFailure
|
||||||
HealthDoesFlush (Just prop )
|
HealthDoesFlush mProp
|
||||||
| prop >= 1 -> HealthFailure
|
| maybe True (>= 2) mProp -> HealthFailure
|
||||||
_other -> maxBound -- Minimum badness
|
_other -> maxBound -- Minimum badness
|
||||||
|
|||||||
@ -224,6 +224,8 @@ data AppSettings = AppSettings
|
|||||||
, appBotMitigations :: Set SettingBotMitigation
|
, appBotMitigations :: Set SettingBotMitigation
|
||||||
|
|
||||||
, appVolatileClusterSettingsCacheTime :: DiffTime
|
, appVolatileClusterSettingsCacheTime :: DiffTime
|
||||||
|
|
||||||
|
, appJobMaxFlush :: Maybe Natural
|
||||||
} deriving Show
|
} deriving Show
|
||||||
|
|
||||||
data JobMode = JobsLocal { jobsAcceptOffload :: Bool }
|
data JobMode = JobsLocal { jobsAcceptOffload :: Bool }
|
||||||
@ -404,6 +406,10 @@ nullaryPathPiece ''SettingBotMitigation $ camelToPathPiece' 3
|
|||||||
pathPieceJSON ''SettingBotMitigation
|
pathPieceJSON ''SettingBotMitigation
|
||||||
pathPieceJSONKey ''SettingBotMitigation
|
pathPieceJSONKey ''SettingBotMitigation
|
||||||
|
|
||||||
|
makePrisms ''JobMode
|
||||||
|
makeLenses_ ''JobMode
|
||||||
|
|
||||||
|
|
||||||
instance FromJSON LdapConf where
|
instance FromJSON LdapConf where
|
||||||
parseJSON = withObject "LdapConf" $ \o -> do
|
parseJSON = withObject "LdapConf" $ \o -> do
|
||||||
ldapTls <- o .:? "tls"
|
ldapTls <- o .:? "tls"
|
||||||
@ -564,7 +570,12 @@ instance FromJSON AppSettings where
|
|||||||
appBearerExpiration <- o .:? "bearer-expiration"
|
appBearerExpiration <- o .:? "bearer-expiration"
|
||||||
appBearerEncoding <- o .: "bearer-encoding"
|
appBearerEncoding <- o .: "bearer-encoding"
|
||||||
|
|
||||||
appHealthCheckInterval <- (assertM' (> 0) . ) <$> o .: "health-check-interval"
|
appJobMode <- o .:? "job-mode" .!= JobsLocal True
|
||||||
|
|
||||||
|
let hciOverride :: HealthCheck -> Maybe NominalDiffTime -> Maybe NominalDiffTime
|
||||||
|
hciOverride HealthCheckDoesFlush _ | is _JobsOffload appJobMode = Nothing
|
||||||
|
hciOverride _ mInterval = mInterval
|
||||||
|
appHealthCheckInterval <- (\f hc -> hciOverride hc . assertM' (> 0) $ f hc) <$> o .: "health-check-interval"
|
||||||
appHealthCheckDelayNotify <- o .: "health-check-delay-notify"
|
appHealthCheckDelayNotify <- o .: "health-check-delay-notify"
|
||||||
appHealthCheckHTTP <- o .: "health-check-http"
|
appHealthCheckHTTP <- o .: "health-check-http"
|
||||||
|
|
||||||
@ -662,8 +673,6 @@ instance FromJSON AppSettings where
|
|||||||
|
|
||||||
appDownloadTokenExpire <- o .: "download-token-expire"
|
appDownloadTokenExpire <- o .: "download-token-expire"
|
||||||
|
|
||||||
appJobMode <- o .:? "job-mode" .!= JobsLocal True
|
|
||||||
|
|
||||||
appStudyFeaturesRecacheRelevanceWithin <- o .:? "study-features-recache-relevance-within"
|
appStudyFeaturesRecacheRelevanceWithin <- o .:? "study-features-recache-relevance-within"
|
||||||
appStudyFeaturesRecacheRelevanceInterval <- o .: "study-features-recache-relevance-interval"
|
appStudyFeaturesRecacheRelevanceInterval <- o .: "study-features-recache-relevance-interval"
|
||||||
|
|
||||||
@ -682,6 +691,8 @@ instance FromJSON AppSettings where
|
|||||||
|
|
||||||
appVolatileClusterSettingsCacheTime <- o .: "volatile-cluster-settings-cache-time"
|
appVolatileClusterSettingsCacheTime <- o .: "volatile-cluster-settings-cache-time"
|
||||||
|
|
||||||
|
appJobMaxFlush <- o .:? "job-max-flush"
|
||||||
|
|
||||||
return AppSettings{..}
|
return AppSettings{..}
|
||||||
where isValidARCConf ARCConf{..} = arccMaximumWeight > 0
|
where isValidARCConf ARCConf{..} = arccMaximumWeight > 0
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
module Utils.Lens ( module Utils.Lens ) where
|
module Utils.Lens ( module Utils.Lens ) where
|
||||||
|
|
||||||
import Import.NoModel
|
import Import.NoModel
|
||||||
import Settings
|
|
||||||
import Model
|
import Model
|
||||||
import Model.Rating
|
import Model.Rating
|
||||||
import qualified ClassyPrelude.Yesod as Yesod (HasHttpManager(..))
|
import qualified ClassyPrelude.Yesod as Yesod (HasHttpManager(..))
|
||||||
@ -277,9 +276,6 @@ makePrisms ''AllocationPriority
|
|||||||
makePrisms ''RoomReference
|
makePrisms ''RoomReference
|
||||||
makeLenses_ ''RoomReference
|
makeLenses_ ''RoomReference
|
||||||
|
|
||||||
makePrisms ''JobMode
|
|
||||||
makeLenses_ ''JobMode
|
|
||||||
|
|
||||||
-- makeClassy_ ''Load
|
-- makeClassy_ ''Load
|
||||||
|
|
||||||
makePrisms ''SchoolAuthorshipStatementMode
|
makePrisms ''SchoolAuthorshipStatementMode
|
||||||
|
|||||||
Reference in New Issue
Block a user