GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [fix][ml] Fix asyncReadEntries might never complete if empty entries are read from BK by BewareMyPower · Pull Request #24515 · apache/pulsar Conversation
|
| ? cursor.getNextAvailablePosition(lastPosition) : lastPosition.getNext(); |
Then updateReadPosition and checkReadCompletion will be skipped, where the result is very similar to #24497 (comment)
asyncReadEntries will never completeentriesReadCount will be updated but the readPosition won'tpendingReadOps will not be reduced to 0Unfortunately, from the existing analysis, the issue of 24497 might not be caused by this bug, but this NPE is still possible.
Remove the confusing lastPosition argument in internalReadEntriesComplete. It's only set when all entries have been filtered out and it needs to reset the readPosition in ManagedLedgerImpl#internalReadFromLedger. It can be replaced by a simple combination of updateReadPosition and checkReadCompletion.
In internalReadEntriesComplete, just call checkReadCompletion when no entries are read to trigger another round of read.
In addition, catch exceptions when triggering user-provided callback and print logs with better information. Without this change, the exception will be caught by SingleThreadTask#safeRunTask and the log will be Error while running task: that does not have description for a specific cursor or read position.
Make EntryCache configurable in tests add add testReadNoEntries to verify that the asyncReadEntries will eventually succeed even if one read operation returns an empty entry list.
doc doc-required doc-not-needed doc-complete PR in forked repository:
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## master #24515 +/- ## ============================================ + Coverage 73.57% 74.31% +0.74% + Complexity 32624 32552 -72 ============================================ Files 1877 1869 -8 Lines 139502 146089 +6587 Branches 15299 16760 +1461 ============================================ + Hits 102638 108569 +5931 + Misses 28908 28900 -8 - Partials 7956 8620 +664
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@lhotari Could you take a look again? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I forgot to submit these minor comments earlier.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@BewareMyPower The "EntryCacheCreator" solution added in this PR is obsolete. There's already a way to intercept reads in Pulsar tests with PulsarMockReadHandleInterceptor. example usage: pulsar/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java Lines 3148 to 3156 in 86b036b
Since the changes to add the "EntryCacheCreator" collide with #24363 changes, I'd suggest that we remove the "EntryCacheCreator" and update the tests added in this PR to use PulsarMockReadHandleInterceptor. I can do a PR to handle that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
the replacement using ReadHandleInterceptor is bkc.setReadHandleInterceptor(new PulsarMockReadHandleInterceptor() { @Override public CompletableFuture<LedgerEntries> interceptReadAsync(long ledgerId, long firstEntry, long lastEntry, LedgerEntries entries) { if (firstRead.compareAndSet(true, false)) { // LedgerEntriesImpl doesn't allow empty entries list. // Implementing a dummy LedgerEntries that returns an empty list. return CompletableFuture.completedFuture(new LedgerEntries() { @Override public org.apache.bookkeeper.client.api.LedgerEntry getEntry(long entryId) { return null; } @Override public Iterator<org.apache.bookkeeper.client.api.LedgerEntry> iterator() { return EmptyIterator.INSTANCE; } @Override public void close() { } }); } else { return CompletableFuture.completedFuture(entries); } } }); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Let me try this approach tomorrow |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I already submitted the PR in #24552 since I'll use that to be able to rebase and test #24363. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…are read from BK (apache#24515) (cherry picked from commit eea7c13) (cherry picked from commit c887259)
…are read from BK (apache#24515) (cherry picked from commit eea7c13) (cherry picked from commit c887259)
…are read from BK (apache#24515) (cherry picked from commit eea7c13) (cherry picked from commit f1974aa)
…are read from BK (apache#24515) (cherry picked from commit eea7c13) (cherry picked from commit c887259)
…are read from BK (apache#24515) (cherry picked from commit eea7c13) (cherry picked from commit f1974aa)
…are read from BK (apache#24515) (cherry picked from commit eea7c13)
…are read from BK (apache#24515) (cherry picked from commit eea7c13)
A batch read that returns no entries at all is completed with the empty result as-is instead of failing, matching what a regular read returns, so the existing handling of empty reads in OpReadEntry (apache#24515, ManagedCursorTest#testReadNoEntries) still applies. A partial result followed by an empty batch still fails, since the full range cannot be assembled.
A hole entry that stops being skipped while its range read is in flight must still be released without delivery: the expected count was reduced by the holes that the scan found, so delivering the entry could reach the count while another range is still in flight, and completing the batch then would advance the read position past that range's entries and drop them. buildRanges now records the intervals of the entries it reads through a merged hole, and BatchReadEntriesCallback always releases those entries, by the scan's result and not by the skip condition's current value. The skip condition still drops the entries the scan did not skip, e.g. ones individually deleted while the read was in flight, and the prefix walk hops over both. An arrival that the filters emptied no longer completes the batch while other ranges are in flight: only an empty batch from the bookie does, as before (apache#24515).
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.