pulsar-client-go
pulsar-client-go copied to clipboard
fix: seek race
Motivation
Broker's seek logic:
- Close the consumer, not connection.
- Move the read position of the cursor.
- Return response to the client.
Seek issue:
- Seek and reconnect requests in the different goroutines, which should be executed serially.
- 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.
Could you review this PR again? @RobertIndie