Repository navigation
Fix reader hanging when startMessageId is latest - #1364
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request addresses a regression in the reader behavior when using a Latest startMessageID by reinstating a check that prevents discarding messages. The key changes include:
- Adding a new test case (TestReaderReadFromLatest) to verify that messages are correctly received when starting from Latest.
- Introducing a new field (seekMessageID) and modifying the seek logic in the partition consumer to correctly set the startMessageID after a seek.
- Reinserting the check for Latest messages in the message discard function.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pulsar/reader_test.go | New test case added to verify behavior when starting from the latest ID. |
| pulsar/consumer_partition.go | Updated seek logic and reintroduced check for Latest, with new field. |
Co-authored-by: Copilot <[email protected]>
codelipenghui
approved these changes
May 12, 2025
shibd
approved these changes
May 14, 2025
RobertIndie
added a commit
that referenced
this pull request
May 15, 2025
* Fix reader hanging when startMessageId is latest * Fix lint * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Add comment to seekMessageId --------- Co-authored-by: Copilot <[email protected]> (cherry picked from commit 2516598)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The Go client version 0.15.0 introduced a regression bug. If the reader's
startMessageIdis set to the latest, it will hang while reading. This issue can be reproduced using the new test case:TestReaderReadFromLatest.Modifications
The root cause is a change in behavior from before version 0.15.0. Previously, the consumer would avoid discarding messages if
startMessageIdwas set to Latest. This logic was altered in this pull request: https://github.com/apache/pulsar-client-go/pull/1340/files#diff-782cf41d23c24657ede53da5d028f05819b302305ed676c61322b4cfba4265e9L1454-L1457The following logic was removed:
In version 0.15.0, if
startMessageIdis Latest, the reader won't receive any messages because all message IDs are before the latest and will be discarded. We need to reinstate this check.For the seek operation, the correct approach is:
seekMessageIdbefore reconnecting.seekMessageIdexists. If it does, it indicates the consumer is seeking, andseekMessageIdshould be set asstartMessageId. This ensures that even if the reader'sstartMessageIdis Latest, it won't receive messages before the specified seek message ID, maintaining the correct behavior as intended in this PR.Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation