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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

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.
  • Shared message channel should be chan *message, not chan []*message.

@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 2 times, most recently from e9582e6 to 4dec08d Compare September 11, 2024 11:05
@nodece nodece marked this pull request as draft September 11, 2024 16:39
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.

2 participants