Skip to content
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

fix: seek race #1265

Merged
merged 4 commits into from
Nov 4, 2024
Merged

fix: seek race #1265

merged 4 commits into from
Nov 4, 2024

Conversation

nodece
Copy link
Member

@nodece nodece commented Aug 1, 2024

Motivation

Broker's seek logic:

  1. Close the consumer, not connection.
  2. Move the read position of the cursor.
  3. Return response to the client.

Seek issue:

  1. Seek and reconnect requests in the different goroutines, which should be executed serially.
  2. Message loss after seek operation based on time: the partitioned topic has multiple consumer partitions, when all seek request is done, the parent consumer will clean up the receive queue, and at the same time, the consumer partition re-reads the message asynchronous. when a message is received, the consumer partition will push the message to the parent consumer, there is a concurrency issue with message cleaning and message push.

Modifications

  • Use the same goroutine to perform the seek and reconnect.
  • The parent consumer pauses receiving messages from all consumer partitions before performing the seek operation and then cleans up the message queue, when the seek is done on the consumer partition, continues to push the message to the parent consumer.

@nodece nodece self-assigned this Aug 1, 2024
@nodece nodece requested a review from RobertIndie August 5, 2024 03:20
@nodece nodece force-pushed the fix-seek-reconnect-race branch 4 times, most recently from 4359d31 to c7c4937 Compare August 10, 2024 18:20
@nodece nodece changed the title fix: fix seek and reconnect race fix: fix seek race Aug 11, 2024
@nodece nodece changed the title fix: fix seek race fix: seek race Aug 11, 2024
@nodece
Copy link
Member Author

nodece commented Aug 11, 2024

Could you review this PR again? @RobertIndie

@nodece nodece force-pushed the fix-seek-reconnect-race branch 3 times, most recently from 4dec08d to 5ec03cb Compare September 11, 2024 16:20
@nodece nodece marked this pull request as draft September 11, 2024 16:39
@nodece nodece force-pushed the fix-seek-reconnect-race branch 5 times, most recently from 6b57cc7 to 6920617 Compare October 12, 2024 09:24
@nodece nodece marked this pull request as ready for review October 12, 2024 10:40
pulsar/consumer_partition.go Show resolved Hide resolved
pulsar/consumer_partition.go Show resolved Hide resolved
pulsar/consumer_partition.go Outdated Show resolved Hide resolved
Copy link
Member

@crossoverJie crossoverJie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nodece nodece merged commit 875f6ba into apache:master Nov 4, 2024
7 checks passed
@nodece nodece added this to the v0.15.0 milestone Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants