Skip to content

fix: seek race - #1265

Merged
nodece merged 4 commits into
apache:masterfrom
nodece:fix-seek-reconnect-race
Nov 4, 2024
Merged

nodece merged 4 commits into
apache:masterfrom
nodece:fix-seek-reconnect-race

Conversation

@nodece

@nodece nodece commented Aug 1, 2024 •

Copy link
Copy Markdown
Member

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 force-pushed the fix-seek-reconnect-race branch from f8cfd6d to 34a8743 Compare August 1, 2024 08:07
Comment thread pulsar/consumer_partition.go Resolved
@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

nodece commented Aug 11, 2024

Copy link
Copy Markdown
Member Author

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
@nodece
nodece force-pushed the fix-seek-reconnect-race branch from 6920617 to 2fb2028 Compare November 1, 2024 08:40
@nodece
nodece requested a review from BewareMyPower November 1, 2024 08:43
Comment thread pulsar/consumer_partition.go Resolved
Comment thread pulsar/consumer_partition.go Resolved
Comment thread pulsar/consumer_partition.go Resolved
@nodece
nodece force-pushed the fix-seek-reconnect-race branch from c0cc57a to 079ec22 Compare November 1, 2024 13:52
@nodece
nodece requested a review from crossoverJie November 1, 2024 14:12
Comment thread pulsar/consumer_partition.go Resolved

@crossoverJie crossoverJie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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