Skip to content

[fix][broker][PIP-195] fix cursor skip read - #19124

Merged
codelipenghui merged 5 commits into
apache:masterfrom
coderzc:fix_cursor_read_skip
Jan 4, 2023
Merged

[fix][broker][PIP-195] fix cursor skip read#19124
codelipenghui merged 5 commits into
apache:masterfrom
coderzc:fix_cursor_read_skip

Conversation

@coderzc

@coderzc coderzc commented Jan 3, 2023

Copy link
Copy Markdown
Member

PIP: #16763

Motivation

In #19035, the skipCondition parameter returns need to skip entry when reading entry, but the logic now is reversed.

Modifications

Fix skip logic and add test to cover it.

Verifying this change

  • Make sure that the change passes the CI checks.

testReadEntriesWithSkip

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Jan 3, 2023
@coderzc coderzc self-assigned this Jan 3, 2023
@coderzc coderzc added this to the 2.12.0 milestone Jan 3, 2023
@coderzc coderzc changed the title [fix][broker] fix cursor skip read [fix][broker][PIP-195] fix cursor skip read Jan 3, 2023
@coderzc coderzc closed this Jan 3, 2023
@coderzc coderzc reopened this Jan 3, 2023
@coderzc
coderzc force-pushed the fix_cursor_read_skip branch from 4a4a1a4 to f1a7bd7 Compare January 3, 2023 15:27
@codecov-commenter

codecov-commenter commented Jan 3, 2023

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.38%. Comparing base (9ec1d07) to head (a32996f).
⚠️ Report is 3041 commits behind head on master.

Files with missing lines Patch % Lines
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #19124      +/-   ##
============================================
- Coverage     47.73%   47.38%   -0.35%     
+ Complexity    10819    10746      -73     
============================================
  Files           712      712              
  Lines         69645    69644       -1     
  Branches       7481     7480       -1     
============================================
- Hits          33242    33000     -242     
- Misses        32699    32944     +245     
+ Partials       3704     3700       -4     
Flag Coverage Δ
unittests 47.38% <0.00%> (-0.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 54.16% <0.00%> (+0.33%) ⬆️

... and 49 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

completableFuture.complete(entries.size());
try {
entries.forEach(entry -> {
assertNotEquals(entry.getEntryId() % 2, 0);

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.

It should be assertEquals(entry.getEntryId() % 2, 0);

And due to this one is executed by the SafeRun, so the test will not get failed event if the assert fails.

@coderzc coderzc Jan 4, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

And due to this one is executed by the SafeRun, so the test will not get failed event if the assert fails.

I already use completableFuture.completeExceptionally(e) to receive exception, it should be can work.

But AssertionError is not a subclass of Exception, so we should be caught Throwable.

image

completableFuture2.complete(entries.size());
try {
entries.forEach(entry -> {
assertEquals(entry.getEntryId() % 2, 0);

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.

Same as the above comment. You might need to consider using a different way to assert the result.

@coderzc
coderzc requested a review from codelipenghui January 4, 2023 03:42
long entryId = firstEntry;
for (; entryId <= lastEntry; entryId++) {
if (opReadEntry.skipCondition.test(PositionImpl.get(ledger.getId(), entryId))) {
if (!opReadEntry.skipCondition.test(PositionImpl.get(ledger.getId(), entryId))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest Invert if condition to help simple understand this logic. : )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok.

}
}

if (firstValidEntry != -1L) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like this logic just works for the else branch. Can we merge it?

@coderzc coderzc Jan 4, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, we can move this logic to the else branch

@coderzc
coderzc force-pushed the fix_cursor_read_skip branch from 5dc2bcc to a32996f Compare January 4, 2023 11:23
@codelipenghui
codelipenghui merged commit 3bb93cb into apache:master Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/broker doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants