SequenceBarrier#waitFor(sequence) bug?

79 views
Skip to first unread message

Julian F

unread,
Sep 28, 2023, 4:32:27 AM9/28/23
to Disruptor
When using a BlockingWaitStrategy, I expect that SequenceBarrier#waitFor(sequence) should block until the value at sequence is ready for consumption. This was the case in 2.x.

But in 3.x, waitFor often returns nextSequence - 1. I believe that this is due to a delay between the sequence being claimed and the sequence being ready for consumption. Is this a bug?

Thank you,
Julian

Julian F

unread,
Sep 28, 2023, 10:57:13 AM9/28/23
to Disruptor
I'm attaching a simple recreation of the behavior I'm seeing. You can run with `mvn test`.
wait-for-bug.tar.gz

Julian F

unread,
Sep 29, 2023, 2:39:41 PM9/29/23
to Disruptor
Just adding links to the relevant source.

When debugging, I found that the blocking wait strategy returns the a sequence greater than or equal to sequence on line 56 of waitFor. But on line 63, sequencer.getHighestPublishedSequence returns sequence - 1.

In 2.10.4, waitFor simply defers to the wait strategy, so sequence - 1 can never be returned with a blocking wait strategy.

Reply all
Reply to author
Forward
0 new messages