Skip to content

Commit

Permalink
Worker: Fixed poller not scheduling concurrent jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Feb 21, 2024
1 parent 9dc1ea1 commit 7b8befc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion IHP/Job/Queue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ pollForJob tableName pollInterval onNewJob = do
forever do
count :: Int <- sqlQueryScalar query params

when (count > 0) (Concurrent.putMVar onNewJob JobAvailable)
when (count > 0) do

This comment has been minimized.

Copy link
@scurtis142

scurtis142 Feb 21, 2024

I believe this when (count > 0) do is now redundant.

This comment has been minimized.

Copy link
@mpscholten

mpscholten Feb 22, 2024

Author Member

Good point, will fix

-- For every job we send one signal to the job workers
-- This way we use full concurrency when we find multiple jobs
-- that haven't been picked up by the PGListener
forEach [0..count] \_ -> do
Concurrent.putMVar onNewJob JobAvailable

-- Add up to 2 seconds of jitter to avoid all job queues polling at the same time
jitter <- Random.randomRIO (0, 2000000)
Expand Down

0 comments on commit 7b8befc

Please sign in to comment.