You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/02 02:05:57 UTC
[GitHub] [pulsar] Demogorgon314 opened a new pull request #13975: [fix][managed-ledger] Fix when nextValidLedger is null caused NPE
Demogorgon314 opened a new pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975
### Motivation
When the `nextValidLedger` is null, `newPosition.getLedgerId() == nextValidLedger` will unboxing of 'nextValidLedger' may produce 'NullPointerException'.
Fortunately, it doesn't cause any behavior bug, it just prints into the log.
NPE log:
```java
2022-01-27T12:34:39,239+0800 [pulsar-io-6-1] WARN org.apache.bookkeeper.mledger.impl.ManagedCursorImpl - Failed to get ledger entries while setting mark-delete-position
java.lang.NullPointerException: null
at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.asyncMarkDelete(ManagedCursorImpl.java:1699) [classes/:?]
at org.apache.pulsar.broker.service.persistent.PersistentSubscription.acknowledgeMessage(PersistentSubscription.java:395) [classes/:?]
at org.apache.pulsar.broker.service.Consumer.messageAcked(Consumer.java:379) [classes/:?]
at org.apache.pulsar.broker.service.ServerCnx.handleAck(ServerCnx.java:1449) [classes/:?]
at org.apache.pulsar.common.protocol.PulsarDecoder.channelRead(PulsarDecoder.java:145) [classes/:?]
```
### Modifications
Check `nextValidLedger ` is null.
### Documentation
Need to update docs?
- [ ] `doc-required`
(If you need help on updating docs, create a doc issue)
- [x] `no-need-doc`
This is a bug fix, no need doc.
- [ ] `doc`
(If this PR contains doc changes)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui commented on a change in pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#discussion_r831280068
##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
##########
@@ -1697,7 +1697,8 @@ public void asyncMarkDelete(final Position position, Map<String, Long> propertie
try {
long ledgerEntries = ledger.getLedgerInfo(markDeletePosition.getLedgerId()).get().getEntries();
Long nextValidLedger = ledger.getNextValidLedger(ledger.getLastConfirmedEntry().getLedgerId());
- shouldCursorMoveForward = (markDeletePosition.getEntryId() + 1 >= ledgerEntries)
+ shouldCursorMoveForward = nextValidLedger != null
+ && (markDeletePosition.getEntryId() + 1 >= ledgerEntries)
&& (newPosition.getLedgerId() == nextValidLedger);
Review comment:
```suggestion
shouldCursorMoveForward = (markDeletePosition.getEntryId() + 1 >= ledgerEntries)
&& (nextValidLedger != null && newPosition.getLedgerId() == nextValidLedger);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 closed pull request #13975: [fix][managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 closed pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1023921836
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on a change in pull request #13975: [fix][managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on a change in pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#discussion_r840432470
##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
##########
@@ -1711,7 +1711,7 @@ public void asyncMarkDelete(final Position position, Map<String, Long> propertie
long ledgerEntries = ledger.getLedgerInfo(markDeletePosition.getLedgerId()).get().getEntries();
Long nextValidLedger = ledger.getNextValidLedger(ledger.getLastConfirmedEntry().getLedgerId());
shouldCursorMoveForward = (markDeletePosition.getEntryId() + 1 >= ledgerEntries)
- && (newPosition.getLedgerId() == nextValidLedger);
+ && (nextValidLedger != null && newPosition.getLedgerId() == nextValidLedger);
Review comment:
Ah, You're right, I have changed it back now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [fix][managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1085611222
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1023177377
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1049541223
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1076143618
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1075969769
> Please also add a test to avoid regression
Is hard to add tests here, the failed only appear in logs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1075970438
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1073843722
@codelipenghui Please help review this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1022894768
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1077010764
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1024852422
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] mattisonchao commented on a change in pull request #13975: [fix][managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
mattisonchao commented on a change in pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#discussion_r840381704
##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
##########
@@ -1711,7 +1711,7 @@ public void asyncMarkDelete(final Position position, Map<String, Long> propertie
long ledgerEntries = ledger.getLedgerInfo(markDeletePosition.getLedgerId()).get().getEntries();
Long nextValidLedger = ledger.getNextValidLedger(ledger.getLastConfirmedEntry().getLedgerId());
shouldCursorMoveForward = (markDeletePosition.getEntryId() + 1 >= ledgerEntries)
- && (newPosition.getLedgerId() == nextValidLedger);
+ && (nextValidLedger != null && newPosition.getLedgerId() == nextValidLedger);
Review comment:
I think we can check ``nextValidLedger != null`` first and then
```java
(markDeletePosition.getEntryId() + 1 >= ledgerEntries)
&& (newPosition.getLedgerId() == nextValidLedger);
```
Please let me know what you think, thanks~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] mattisonchao commented on a change in pull request #13975: [fix][managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
mattisonchao commented on a change in pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#discussion_r840381704
##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
##########
@@ -1711,7 +1711,7 @@ public void asyncMarkDelete(final Position position, Map<String, Long> propertie
long ledgerEntries = ledger.getLedgerInfo(markDeletePosition.getLedgerId()).get().getEntries();
Long nextValidLedger = ledger.getNextValidLedger(ledger.getLastConfirmedEntry().getLedgerId());
shouldCursorMoveForward = (markDeletePosition.getEntryId() + 1 >= ledgerEntries)
- && (newPosition.getLedgerId() == nextValidLedger);
+ && (nextValidLedger != null && newPosition.getLedgerId() == nextValidLedger);
Review comment:
I think we can check ``nextValidLedger != null`` first and then
```java
(markDeletePosition.getEntryId() + 1 >= ledgerEntries)
&& (newPosition.getLedgerId() == nextValidLedger);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 edited a comment on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 edited a comment on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1075969769
> Please also add a test to avoid regression
@codelipenghui
Is hard to add tests here, the fails only appear in logs, do you have a better idea?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Demogorgon314 commented on pull request #13975: [managed-ledger] Fix when nextValidLedger is null caused NPE
Posted by GitBox <gi...@apache.org>.
Demogorgon314 commented on pull request #13975:
URL: https://github.com/apache/pulsar/pull/13975#issuecomment-1049651882
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org