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][client] fix Reader.hasMessageAvailable might return true after seeking to latest #30

Closed

Conversation

BewareMyPower
Copy link
Owner

Motivation

Java client has the same issue with
apache/pulsar-client-python#199

After a seek operation is done, the startMessageId will be updated until the reconnection due to the seek is done in connectionOpened. So before it's updated, hasMessageAvailable could compare with an outdated startMessageId and return a wrong value.

Modifications

Replace duringSeek with a SeekStatus field:

  • NOT_STARTED: initial, or a seek operation is done. seek could only succeed in this status.
  • IN_PROGRESS: A seek operation has started but the client does not receive the response from broker.
  • COMPLETED: The client has received the seek response but the seek future is not done.

After the status becomes COMPLETED, next time the connection is established, the status will change from COMPLETED to NOT_STARTED and then seek future will be completed in the internal executor.

Add testHasMessageAvailableAfterSeek to cover this change.

…seeking to latest

### Motivation

Java client has the same issue with
apache/pulsar-client-python#199

After a seek operation is done, the `startMessageId` will be updated
until the reconnection due to the seek is done in `connectionOpened`. So
before it's updated, `hasMessageAvailable` could compare with an
outdated `startMessageId` and return a wrong value.

### Modifications

Replace `duringSeek` with a `SeekStatus` field:
- `NOT_STARTED`: initial, or a seek operation is done. `seek` could only
  succeed in this status.
- `IN_PROGRESS`: A seek operation has started but the client does not
  receive the response from broker.
- `COMPLETED`: The client has received the seek response but the seek
  future is not done.

After the status becomes `COMPLETED`, if the connection is not ready,
next time the connection is established, the status will change from
`COMPLETED` to `NOT_STARTED` and then seek future will be completed in
the internal executor.

Add `testHasMessageAvailableAfterSeek` to cover this change.
@BewareMyPower BewareMyPower force-pushed the bewaremypower/fix-seek-has-msg-available branch from 79ad518 to 5f09ec7 Compare March 5, 2024 07:41
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-seek-has-msg-available branch March 26, 2024 02:34
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.

1 participant