Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions consumers/src/Database/PostgreSQL/Consumers/Components.hs
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,13 @@ spawnDispatcher ConsumerConfig {..} cs cid semaphore runningJobsInfo runningJobs
jobIds :: [idx] <- fetchMany runIdentity
if null jobIds
then pure []
else
else do
handle
( \(SomeException e) -> do
( \(DBException _ _ e _) -> do
logAttention "Failure to fetch the jobs, will reenqueue for the next day" $ object ["error" .= show e, "job_ids" .= show jobIds]
rollback
lift $ fetchFailureHandler jobIds
pure []
pure ()
)
( do
runPreparedSQL_ (preparedSqlName "setReservation" ccJobsTable) $
Expand All @@ -397,16 +397,16 @@ spawnDispatcher ConsumerConfig {..} cs cid semaphore runningJobsInfo runningJobs
, "WHERE id = ANY(" <?> Array1 jobIds <+> ")"
, "RETURNING id, " <+> mintercalate ", " ccJobSelectors
]
qr <- queryResult
results <- forM (F.toList qr) $ \(rawJobId :*: other) -> do
let jobId = runIdentity rawJobId
(Just <$> liftBase (evaluate $ ccJobFetcher other)) `catch` \(SomeException e) -> do
logAttention "Failure to fetch job, will reenqueue for the next day" $ object ["error" .= show e, "job_id" .= show jobId]
rollback
lift $ fetchFailureHandler [jobId]
pure Nothing
pure $ catMaybes results
)
qr <- queryResult
results <- forM (F.toList qr) $ \(rawJobId :*: other) -> do
let jobId = runIdentity rawJobId
(Just <$> liftBase (evaluate $ ccJobFetcher other)) `catch` \(DBException _ _ e _) -> do
logAttention "Failure to fetch job, will reenqueue for the next day" $ object ["error" .= show e, "job_id" .= show jobId]
rollback
lift $ fetchFailureHandler [jobId]
pure Nothing
pure $ catMaybes results

fetchFailureHandler :: [idx] -> m ()
fetchFailureHandler jobIds = do
Expand Down
Loading