-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fixed reader cursor seek with disconnection #5278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@merlimat I have check the logic but not found how to handle that reset cursor to a historical position and then consumer call acknowledgeCumulative() with messageId which is dispatched to this consumer before. If disconnect all consumers while reset cursor, client will create new consumers, that's not going to happen. Maybe i missed something. |
|
retest this please |
|
run java8 tests |
|
@merlimat If we don't disconnect the consumers, how do consumers reset their state? e.g. pending queue, acknowledgement, and etc. |
Consumers they won't reset, they just will see the messages restart from an earlier (or later) point in time. I don't believe that should affect the consumer logic since there will be no visible disruption from consumer perspective. |
It can still happen, and actually it's more probable to happen the longer the ack is delayed from the receival of the message. Even if the consumer session is recreated, a consumer can receive a message, then seek it's triggered and then it will call ack-cumulative returning the cursor to the previous position. An application that seeks while acking (either individual or cumulative) is bound to unpredictable behavior in any case, irrespective of the disconnection. |
|
@merlimat I changed the milestone to 2.4.2. |
|
seems the test failures related with this change: |
Maybe Sijie was concern about the messages that already cached in consumer client. We may need some handling to clean the cached messages? |
|
@merlimat I wasn't sure how is the ordering guaranteed if we don't clean up the cached message. Can you clarify it? |
|
Moved this to 2.5.0 since I think it requires some more discussions about the side effect of this change. |
|
actually moved to 2.4.3 |
|
@bsideup thank you for your updates. Do these N sessions belong to one subscription? |
|
@sijie yes, they listen to the same topic / partition with failover |
|
@bsideup sorry. if they are in the same subscription, it is expected that all consumers in the same subscription to reset to the new cursor position if the cursor is reset from a correctness perspective. I see what can be improved here is when the broker disconnects the consumers, it can disconnect the active consumers only. For exclusive/failover subscription, it will only reset the consumer that is currently active. This seems to be a correct fix. @codelipenghui @merlimat what do you think? |
|
@merlimat I move it to 2.7.0 and feel free to move it back if you want to onboard it in 2.6.0. |
|
@codelipenghui it is sad to see it being moved over and over 😞 It is a blocker for failover subscriptions with external offset management, and the implemented behaviour is rather questionable. What's the reason to move it (again)? |
|
@bsideup Thanks for your feedback, I didn't notice that it is a blocker before. I will move it back to 2.6.0 and could you please take a look at sijie's last comment? Is the approach works for you? |
|
@bsideup I have pushed a PR #7141 which based on sijie's comment #5278 (comment). Could you please help review the changes? |
|
@codelipenghui looks promising! Looking forward to trying it 👍 |
) Related to #5278 ### Motivation Only close active consumer for Failover subscription when seek(). ### Verifying this change Unit tests added ### Does this pull request potentially affect one of the following parts: *If `yes` was chosen, please highlight the changes* - Dependencies (does it add or upgrade a dependency): ( no) - The public API: (no) - The schema: (no) - The default values of configurations: (no) - The wire protocol: (no) - The rest endpoints: (no) - The admin cli options: (no) - Anything that affects deployment: (no) ### Documentation - Does this pull request introduce a new feature? (no)
…ache#7141) Related to apache#5278 ### Motivation Only close active consumer for Failover subscription when seek(). ### Verifying this change Unit tests added ### Does this pull request potentially affect one of the following parts: *If `yes` was chosen, please highlight the changes* - Dependencies (does it add or upgrade a dependency): ( no) - The public API: (no) - The schema: (no) - The default values of configurations: (no) - The wire protocol: (no) - The rest endpoints: (no) - The admin cli options: (no) - Anything that affects deployment: (no) ### Documentation - Does this pull request introduce a new feature? (no)
@codelipenghui PR #7141 doesn't seem to help with Pulsar Readers since Readers are always using exclusive subscriptions under the covers (
@codelipenghui would it be possible to extend the solution that was made in #7141 to also cover Readers? |
Motivation
Currently the seek() operation will first disconnect all the connected consumers and then reset the cursor. This was due initially to simplify the logic and avoid concurrent operations.
Adding it now, so that consumers won't get disconnected/reconnected while the seek is performed.