Skip to content

take seek time into account in Reader#hasMessageAvailable - #7848

Closed
aloyszhang wants to merge 10 commits into
apache:masterfrom
aloyszhang:seek-hasavailable
Closed

aloyszhang wants to merge 10 commits into
apache:masterfrom
aloyszhang:seek-hasavailable

Conversation

@aloyszhang

@aloyszhang aloyszhang commented Aug 19, 2020 •

Copy link
Copy Markdown
Contributor

Fixes #7796

Motivation

This PR takes seek time into account in Reader#hasMessageAvailable.

Modifications

  1. mark the timestamp in Reader when seek(timestamp)
  2. compare the marked timestamp with the publish time of last messag to decide Reader#hasMessageAvailable give true or false

@aloyszhang

aloyszhang commented Aug 19, 2020 •

Copy link
Copy Markdown
Contributor Author

@sijie @jiazhai CI failed when build pulsar image , error information

[ERROR] The command '/bin/sh -c /pulsar/bin/install-pulsar-client-27.sh' returned a non-zero code: 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  20:24 min
[INFO] Finished at: 2020-08-19T06:51:53Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.13:build (default) on project pulsar-docker-image: Could not build image: The command '/bin/sh -c /pulsar/bin/install-pulsar-client-27.sh' returned a non-zero code: 1 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
##[error]Process completed with exit code 1.

It seems have nothing to do with this PR. Any suggestions for resolving this CI problem?

@aloyszhang

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui

Copy link
Copy Markdown
Contributor

@aloyszhang You can try to rebase the apache master branch

@aloyszhang

Copy link
Copy Markdown
Contributor Author

@codelipenghui Thanks ,I will try it.

@codelipenghui codelipenghui left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the broker should return the start message id to the client when handling the seek request. So that we can update the startMessageId of the consumer to the responded message id.

If we return the publish time and return has available messages according to the time, the clocks of the client and server must be consistent. Aways use message id to calculate have available messages is more reasonable.

@aloyszhang

aloyszhang commented Aug 21, 2020 •

Copy link
Copy Markdown
Contributor Author

@codelipenghui
Thanks for your reply. I think use message id is a alternative way.
But I don't think clock time is an issue, since both the publish time and seek time are specified from the client side.
Using publish time and seek time to decides whether have available messages make sence for me.

Think about this case,
if we seek at a timestamp after publish time of the last message, there should be no messages available.
But if we use MessageId to decides whether have available messages ,

  1. the seek(Timestamp) will return with the last messageId
  2. the getLastMessageId also return the last messageId
  3. if resetIncludeHead is true

hasMessageAvailable will return true, and this is not right. So in this case, we should do more border control to keep it works well.

@aloyszhang

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@aloyszhang

Copy link
Copy Markdown
Contributor Author

@codelipenghui @jiazhai CI failed all the time, PATL.

@codelipenghui

Copy link
Copy Markdown
Contributor

@aloyszhang

Thanks for your reply. I think use message id is a alternative way.
But I don't think clock time is an issue, since both the publish time and seek time are specified from the client side.
Using publish time and seek time to decides whether have available messages make sence for me.

the publish time and the seek time may be assigned by the different client, right?

@aloyszhang

Copy link
Copy Markdown
Contributor Author

@codelipenghui

the publish time and the seek time may be assigned by the different client, right?

Yes, the publish time and the seek time can be assigned by different client. But in my opoion, maybe Clock synchronization issue can be ignored. Since, if we consider Clock synchronization among all client, the Reader#seek also has problem if client seek message published by other client.

@aloyszhang

Copy link
Copy Markdown
Contributor Author

@codelipenghui Does this pr need more discuss?

@aloyszhang
aloyszhang force-pushed the seek-hasavailable branch 2 times, most recently from 0b3bbe0 to 668aa05 Compare September 7, 2020 11:07
@aloyszhang

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@aloyszhang

Copy link
Copy Markdown
Contributor Author

cc @codelipenghui

@jiazhai

jiazhai commented Sep 9, 2020

Copy link
Copy Markdown
Member

@aloyszhang Thanks for the contribution. I agree with Penghui, we should make ledgerId/entryId as the source of truth.

@aloyszhang

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@sijie

sijie commented Oct 15, 2020

Copy link
Copy Markdown
Member

@aloyszhang Is the change ready for review again?

@aloyszhang

Copy link
Copy Markdown
Contributor Author

@sijie I'll check whether failed CI has relation to this PR or not soon.

@aloyszhang
aloyszhang force-pushed the seek-hasavailable branch 3 times, most recently from 0cec215 to f1259d0 Compare October 22, 2020 15:07
@aloyszhang

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@aloyszhang

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@aloyszhang

aloyszhang commented Dec 8, 2020 •

Copy link
Copy Markdown
Contributor Author

@codelipenghui PTAL

@aloyszhang

Copy link
Copy Markdown
Contributor Author

ping @sijie @codelipenghui @jiazhai Would you please take a look about this PR?

@jiazhai

jiazhai commented Dec 19, 2020

Copy link
Copy Markdown
Member

@codelipenghui Since this PR changes the seek response from CommandSuccess to CommandSeekResponse, the other clients may fail with seek. Is it proper to include this PR in 2.7.1? Because the other clients may work well with 2.7.0 but fail with 2.7.1. I'm just curious about the compatibility among x.y.0 and x.y.z.

This would be an issue

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to send the new type of response only to newer clients and preserve old behaviour in case of an old client.

Btw this change cannot go into 2.7.1, it is a wire protocol change, it can be only from 2.8.0

@zymap

zymap commented Feb 22, 2021

Copy link
Copy Markdown
Member

Remove the release/2.7.1 tag because of changing the proto file.

@codelipenghui

Copy link
Copy Markdown
Contributor

ping @315157973 Could you please help take a look at this issue? Seems related to #10414

@315157973

Copy link
Copy Markdown
Contributor

ping @315157973 Could you please help take a look at this issue? Seems related to #10414

This problem has always been there, and it is not caused by my PR. This PR also fixes the problem of the reader, all hasMessageAvailable returns true, but the message cannot be read.

return new MessageIdImpl(ledgerId, entryId, -1);
}

public static int getBathIndexFromMessageIdData(PulsarApi.MessageIdData messageIdData) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be getBatchIndexFromMessageIdData

@eolivelli eolivelli modified the milestones: 2.9.0, 2.10.0 Oct 6, 2021
@codelipenghui codelipenghui modified the milestones: 2.10.0, 2.11.0 Jan 18, 2022
@github-actions

github-actions Bot commented Mar 4, 2022

Copy link
Copy Markdown

@aloyszhang:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@tisonkun

Copy link
Copy Markdown
Member

Closed as stale and conflict. Please rebase and resubmit the patch if it's still relevant.

@tisonkun tisonkun closed this Dec 10, 2022
@aloyszhang
aloyszhang deleted the seek-hasavailable branch August 17, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reader#hasMessageAvailable give wrong value after Reader#seek

10 participants