Skip to content

i1.39.9

@glevkovich glevkovich tagged this 22 Jul 12:43
Since v1.38 the async_dispatch_quota anti-starvation logic in AsyncFiber
could run a pipelined command such as UNSUBSCRIBE ahead of pub/sub
messages that were queued before it, once the quota was reached. Running
UNSUBSCRIBE early sets subscriptions to 0, so the still-queued messages
are discarded and the subscriber loses messages published before it
unsubscribed.

Gate the quota-based pipeline preference on FIFO order: only prefer the
pipeline when its head command is strictly older than the oldest queued
control message, so it never jumps ahead of pub/sub messages queued
before it.

dispatch_q_ is FIFO by dispatch_cycle except for checkpoints, which
SendAsync inserts at the front. A newer leading checkpoint would hide
older queued PubMessages, so when the head is a checkpoint we defer the
pipeline preference for one iteration: the checkpoint is processed first
and the decision is re-evaluated against the real oldest message.

Add regression test test_pubsub_unsubscribe_message_loss.

The V2 io loop (IoLoopV2) fix will be done in a separate commit; the
test is skipped under V2 until then.

Signed-off-by: Gil Levkovich <69595609+glevkovich@users.noreply.github.com>
Assets 2
Loading