Skip to content
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

Closed
wants to merge 9 commits into from
Closed

Conversation

casuallc
Copy link
Contributor

Fixes #11796

No need doc.

@Anonymitaet Anonymitaet added the doc-not-needed Your PR changes do not impact docs label Oct 18, 2021
OpReadEntry op = OpReadEntry.create(this, readPosition, numOfEntriesToRead, callback, ctx, maxPosition);
ledger.asyncReadEntries(op);
if (op != null) {
Copy link
Contributor

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?

Copy link
Contributor Author

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 .

Copy link
Contributor

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.

@casuallc
Copy link
Contributor Author

casuallc commented Nov 5, 2021

@codelipenghui Do you think my solution is suitable?

By the way, I add test.

lhotari
lhotari previously approved these changes Nov 19, 2021
@casuallc
Copy link
Contributor Author

/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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My point is :

  • readEntriesComplete or readEntriesFailed must be called in any case, so read event would always receive response.
  • OpReadEntry should be recyle in readEntriesComplete or readEntriesFailed.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Member

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.

Copy link
Member

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.

@zymap
Copy link
Member

zymap commented Dec 3, 2021

Please revert the change of site2/website-next/scripts/docker.sh 100755 → 100644. That may cause the script without execute permission. @casuallc

@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@lhotari
Copy link
Member

lhotari commented Apr 8, 2022

@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);
Copy link
Member

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.

@horizonzy
Copy link
Member

readPosition = cursor.ledger.startReadOperationOnLedger(nextReadPosition, OpReadEntry.this);

here also need handle, this change maybe not cover all situation. coud you see #15098, maybe it's better to fix problem.

@tisonkun
Copy link
Member

Closed as stale and conflicts.

@tisonkun tisonkun closed this Nov 14, 2022
@tisonkun
Copy link
Member

Fixed by #15837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

throw NPE when readEntry
8 participants