zalky / cues

Queues on cue: low-latency persistent blocking queues, processors, and graphs via Chronicle Queue
Apache License 2.0
105 stars 2 forks source link

Multiple non-persistent tailers on one queue do not always unblock #1

Closed zalky closed 1 year ago

zalky commented 1 year ago

When more than one non-persistent tailer (any tailer without an id) are created on the same queue, only one of them will unblock.

This does not affect either persistent tailers (any tailer that has been given an id), or any tailers that participate in graphs (all tailers that particpate in graphs have an id).

Repro

The following will hang on the last line:

(let [done-1 (promise)
      done-2 (promise)
      q      (q/queue ::tmp)
      t1     (q/tailer q) ; no id given
      t2     (q/tailer q) ; no id given
      a      (q/appender q)]
  (future (deliver done-1 (q/read!! t1)))
  (future (deliver done-2 (q/read!! t2)))
  (Thread/sleep 1)
  (q/write a {:x 1})
  (= @done-2 {:x 1})
  (= @done-1 {:x 1}))

The solution is to ensure all tailers have ids: non-persistent tailers receive ephemeral ids that are not passed along on the ChronicleQueue tailer constructor.

The user facing API does not change.