Skip to content

Commit 20e1ef9

Browse files
author
Nathan Marz
committed
resolve #99 by making the timer lock completely independent from the submit lock. the timer releases the lock before calling the task function.
1 parent 619f2fd commit 20e1ef9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/clj/backtype/storm/timer.clj

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
(let [[time-secs _ _ :as elem] (.peek queue)]
2929
(if elem
3030
(if (>= (current-time-secs) time-secs)
31-
(locking lock
32-
((second (.poll queue))))
31+
;; can't hold the lock while executing the task function, or else
32+
;; deadlocks are possible (if the task function locks another lock
33+
;; and another thread locks that other lock before trying to schedule
34+
;; something on the timer)
35+
(let [exec-fn (locking lock (second (.poll queue)))]
36+
(exec-fn))
3337
(Time/sleepUntil (to-millis time-secs))
3438
)
3539
(Time/sleep 10000)

0 commit comments

Comments
 (0)