-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] Java Client's Seek Logic Not Threadsafe #1 #20242
[fix][client] Java Client's Seek Logic Not Threadsafe #1 #20242
Conversation
Could you add a test for your changes? |
Sure! Will do in bit. Can I ask for your opinion, @nodece ? Do you think we should...
Because since the change is made in a private method I am trying to test through either of two methods, pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java Line 2168 in e0b50c9
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java Line 2178 in e0b50c9
but I have not succeeded in finding a test I can refer to except below test from broker seems to cover too much. pulsar/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java Line 185 in 9cb0503
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we set:
MessageIdAdv originSeekMessageId = seekMessageId;
seekMessageId = (MessageIdAdv) seekId;
after the check passed?
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Show resolved
Hide resolved
@JooHyukKim BTW, edit comment won't send notification, I suggest you create new comment when you'd like to notify reviewers. |
I'd appreciate it if you can provide a timing diagram to prove the fix. You may refer to apache/curator#430 as a typical description. |
How to verify your changes? You can set |
Right, thank you for the reminder 👍🏻 |
Np 👍🏻. May I ask what tool everyone conventionally uses? Or your suggestion @tisonkun ? |
Generally, I just write in text :D It's about:
But any tool you searched is acceptable as long as the diagram is clear (with text, reviewers manually dump to diagram). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait a bit for review from @michaeljmarshall.
This patch looks good to me.
Thank you for the tips! |
@JooHyukKim Please fix style violation by yourself. You can use CI workflow in your personal fork to verify. Or the command should be:
Ping me once CI passed in your personal fork. |
/pulsarbot rerun-failure-checks |
Thank you @tisonkun, I made below two check style commands pass, "locally". My personal fork is not running CI. Is it supposed to run though? 🤔🤔
|
Yes. You may take lhotari#145 as an example. IIRC GitHub sometimes stuck on turning on Actions..I don't have too much suggestions here but I used to follow the instructions in Actions tab to add a sample workflow and then GitHub turn on Actions. |
/pulsarbot rerun-failure-checks |
Codecov Report
@@ Coverage Diff @@
## master #20242 +/- ##
============================================
- Coverage 72.87% 72.86% -0.02%
+ Complexity 31943 3601 -28342
============================================
Files 1868 1868
Lines 138594 138597 +3
Branches 15246 15247 +1
============================================
- Hits 101003 100991 -12
- Misses 29547 29557 +10
- Partials 8044 8049 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Merging... Thanks for your contribution! |
@JooHyukKim May I ask what |
Oh... 😅 "#1" means My first ever contribution to Pulsar! I can remove the "#1" part from title if you think it will confuse the maintenance team. Just let me know~ 🙏🏼 @tisonkun
@tisonkun Thank you for great guidance on your part 🙏🏼 |
Never mind. I can edit the commit message before merging :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @JooHyukKim! Would you mind updating the Javadoc for the seek
and seekAsync
methods to indicate what will happen if a user calls a seek method before a previous call completes? Here is a reference to one of the Javadocs:
pulsar/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Consumer.java
Lines 529 to 537 in a918651
/** | |
* Reset the subscription associated with this consumer to a specific message publish time. | |
* | |
* @param timestamp | |
* the message publish time where to reposition the subscription | |
* The timestamp format should be Unix time in milliseconds. | |
* @return a future to track the completion of the seek operation | |
*/ | |
CompletableFuture<Void> seekAsync(long timestamp); |
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Show resolved
Hide resolved
Will do! 🙏🏽 Later after work 😀 |
@tisonkun |
@Technoboy- Thanks for setting up the milestone.
Yep. I'm investigating some tools to unify whitespace so that we don't ask for aligning again and again. |
This reverts commit bc1764f.
(cherry picked from commit bc1764f)
Fixes #19671
Motivation
To resolve the thread-safety issue around Java client's seek logic identified by #19671.
Modifications
duringSeek
flag is not false.Verifying this change
I am not sure if my PR went through the intended CI checks...?
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: https://github.com/JooHyukKim/pulsar/pull/1