git.iko.soy/typeable/katip-rollbar
on master help sign in
Fix MVar blocking

If we try to atomically clear the queue, we can sometimes never finish clearing it. This will cause the `finalize` mvar to be blocked for too long. The runtime system things the mvar is blocked indefinitely, and kills everything. Rather, we should not try to atomically clear the queue. Let each worker finish when they finish. And just wait until everything is done.

commit77326dbfe9ad618b5119104b21bacf9431013926 authorjoneshf <jones3.hardy@gmail.com> dateMon 19 Feb 2018, 02:02 (9 years ago) parent5bc27cb
1 file changed+3−4
src/Katip/Scribes/Rollbar.hs+3−4
src/Katip/Scribes/Rollbar.hs+3−4
@@ -16,7 +16,7 @@ import "base" Data.Foldable (for_)
1616import "base" Data.Functor (void)
1717import "base" GHC.Conc (atomically)
1818
19−import "async" Control.Concurrent.Async (async, waitCatchSTM)
19+import "async" Control.Concurrent.Async (async, waitCatch)
2020import "stm-chans" Control.Concurrent.STM.TBMQueue
2121 ( TBMQueue
2222 , closeTBMQueue
@@ -151,9 +151,8 @@ setupWorkers ::
151151setupWorkers proxy queue finalize manager = void $ async $ do
152152 workers <- replicateM workerSize (async $ mkWorker proxy manager queue)
153153 takeMVar finalize
154− atomically $ do
155− closeTBMQueue queue
156− for_ workers waitCatchSTM
154+ atomically (closeTBMQueue queue)
155+ for_ workers waitCatch
157156 putMVar finalize ()
158157
159158mkWorker ::