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 2018/04/11 23:43:30 UTC
[GitHub] rdhabalia opened a new pull request #1554: Fix: handle invalid
markDelete position at managed-cursor
rdhabalia opened a new pull request #1554: Fix: handle invalid markDelete position at managed-cursor
URL: https://github.com/apache/incubator-pulsar/pull/1554
### Motivation
If client acks with invalid message-id (message-id > ledger.lastConfirmedEntry) then broker doesn't do validation and it tries to process it which can corrupt the state of cursor.
eg: if `newMarkDeletePosition` is invalid then [ledger.getNextValidPosition()](https://github.com/apache/incubator-pulsar/blob/branch-1.22/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java?utf8=%E2%9C%93#L1245) returns null and broker stores `readPosition=null`
```
readPosition = ledger.getNextValidPosition(newMarkDeletePosition);
```
and it creates below exception:
```
19:17:28.298 [pulsar-io-72-47] WARN o.a.b.mledger.impl.ManagedCursorImpl - [prop/global/ns/persistent/topic] [sub] Error while updating individualDeletedMessages [null]
java.lang.NullPointerException: null
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:192) ~[guava-15.0.jar:na]
at com.google.common.collect.TreeRangeSet.rangeContaining(TreeRangeSet.java:98) ~[guava-15.0.jar:na]
at com.google.common.collect.AbstractRangeSet.contains(AbstractRangeSet.java:29) ~[guava-15.0.jar:na]
at com.google.common.collect.TreeRangeSet.contains(TreeRangeSet.java:42) ~[guava-15.0.jar:na]
at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.setAcknowledgedPosition(ManagedCursorImpl.java:1248) ~[managed-ledger-1.20.16-incubating-yahoo.jar:1.20.16-incubating-yahoo]
at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.asyncDelete(ManagedCursorImpl.java:1541) ~[managed-ledger-1.20.16-incubating-yahoo.jar:1.20.16-incubating-yahoo]
at org.apache.pulsar.broker.service.persistent.PersistentSubscription.acknowledgeMessage(PersistentSubscription.java:182) [pulsar-broker-1.20.16-incubating-yahoo.jar:1.20.16-incubating-yahoo]
at org.apache.pulsar.broker.service.Consumer.messageAcked(Consumer.java:346) [pulsar-broker-1.20.16-incubating-yahoo.jar:1.20.16-incubating-yahoo]
at org.apache.pulsar.broker.service.ServerCnx.handleAck(ServerCnx.java:859) [pulsar-broker-1.20.16-incubating-yahoo.jar:1.20.16-incubating-yahoo]
```
### Modifications
validate mark-delete position before processing it.
### Result
Prevents any state corruption at cursor.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services