Skip to content

Fix NPE when create OpEntry#12396

Closed
casuallc wants to merge 9 commits into
apache:masterfrom
casuallc:op_entry_npe
Closed

Fix NPE when create OpEntry#12396
casuallc wants to merge 9 commits into
apache:masterfrom
casuallc:op_entry_npe

Conversation

@casuallc

Copy link
Copy Markdown
Contributor

Fixes #11796

No need doc.

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

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.

Could you please provide more information about why op could be null?

Copy link
Copy Markdown
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
Copy Markdown
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

casuallc commented Nov 5, 2021

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

op.ctx = ctx;
PositionImpl position = cursor.ledger.startReadOperationOnLedger(readPositionRef, op);
if (position == null) {
return null;

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.

We can recycle this OpReadEntry if we return null.

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

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 might be better to skip recycling of failed entries. That was something that was recently removed for OpAddEntry instances in #12993.

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.

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

zymap commented Dec 3, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown

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

@lhotari

lhotari commented Apr 8, 2022

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Closed as stale and conflicts.

@tisonkun tisonkun closed this Nov 14, 2022
@tisonkun

Copy link
Copy Markdown
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