-
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 NPE when create OpEntry #12396
Fix NPE when create OpEntry #12396
Conversation
OpReadEntry op = OpReadEntry.create(this, readPosition, numOfEntriesToRead, callback, ctx, maxPosition); | ||
ledger.asyncReadEntries(op); | ||
if (op != null) { |
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.
Could you please provide more information about why op could be null?
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.
@codelipenghui This PR is used to solve NPE, is a copy of #11813 .
If op is null, the read faild event would be trigger.
There is another solution, see #11292 .
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.
It will be very dangerous if the dispatcher call read entries but can't receive any response, I think the broker will stop dispatching messages.
@codelipenghui Do you think my solution is suitable? By the way, I add test. |
/pulsarbot run-failure-checks |
@@ -58,6 +57,11 @@ public static OpReadEntry create(ManagedCursorImpl cursor, PositionImpl readPosi | |||
} | |||
op.maxPosition = maxPosition; | |||
op.ctx = ctx; | |||
PositionImpl position = cursor.ledger.startReadOperationOnLedger(readPositionRef, op); | |||
if (position == null) { | |||
return null; |
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.
We can recycle this OpReadEntry if we return null.
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.
My point is :
readEntriesComplete
orreadEntriesFailed
must be called in any case, so read event would always receive response.OpReadEntry
should be recyle inreadEntriesComplete
orreadEntriesFailed
.
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.
+1
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.
It might be better to skip recycling of failed entries. That was something that was recently removed for OpAddEntry instances in #12993.
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.
yes, I guess readEntriesFailed
would have to be called before returning null so that the comment by @codelipenghui in https://github.com/apache/pulsar/pull/12396/files#r754321070 could be addressed.
Please revert the change of |
The pr had no activity for 30 days, mark with Stale label. |
@casuallc Please rebase the changes |
@@ -2154,6 +2154,7 @@ PositionImpl startReadOperationOnLedger(PositionImpl position, OpReadEntry opRea | |||
if (null == ledgerId) { | |||
opReadEntry.readEntriesFailed(new ManagedLedgerException.NoMoreEntriesToReadException("The ceilingKey(K key) method is used to return the " + | |||
"least key greater than or equal to the given key, or null if there is no such key"), null); |
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.
still npe, can't pass on null ctx, in the process of callback, need use it.
pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpReadEntry.java Line 147 in af35164
here also need handle, this change maybe not cover all situation. coud you see #15098, maybe it's better to fix problem. |
Closed as stale and conflicts. |
Fixed by #15837 |
Fixes #11796
No need doc.