merlimat opened a new pull request #7106:
URL: https://github.com/apache/pulsar/pull/7106


   Note: this is based on top of #6791, #7104 and #7105. Once these are merged, 
I'll rebase here. For the sake of this review, check commit ad2e39be36
   
   
   ### Motivation
   
   Fixes:  #6554
   
   Ordering is broken in KeyShared dispatcher if a new consumer `c2` comes in 
and an existing consumer `c1` goes out. 
   
   This is because messages with keys previously assigned to `c1` may now route 
to `c2`. 
   
   The solution here is to have new consumers joining in a "paused" state.
   
   For example, consider this sequence:
   
    1. Subscriptions has `c1` and `c2` consumers
    2. `c3` joins. Some of the keys are now supposed to go to `c3`.
    3. Instead of starting delivering to `c3`. We mark the current readPosition 
(let's call it `rp0_c3`) of the cursor for `c3`.
    4. Any message that now hashes to `c3` and that has `messageId >= rp0_c3` 
will be deferred for later re-delivery
    5. Any message that might get re-delivered (eg: originally sent to `c1`, 
but `c1` has failed) to `c3` and that has `messageId < rp0_c3` will be sent to 
`c3`
    6. When the markDelete position of the cursor will move past `rp0_c3` the 
restriction on `c3` will be lifted.
   
   Essentially, `c3` joins but can only receive old messages, until everything 
that was read before joining gets acked.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to