You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "mingyifei (via GitHub)" <gi...@apache.org> on 2023/03/14 15:10:56 UTC
[GitHub] [pulsar] mingyifei opened a new issue, #19808: [Bug]
mingyifei opened a new issue, #19808:
URL: https://github.com/apache/pulsar/issues/19808
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Version
2.11
org.apache.bookkeeper.mledger.impl.OpFindNewest#readEntryComplete
### Minimal reproduce step

1.state = checkFirst, condition.apply(entry) = true
The following code is executed:
```
lastMatchedPosition = position;
// check last entry
state = State.checkLast;
PositionImpl lastPosition = ledger.getLastPosition();
searchPosition = ledger.getPositionAfterN(searchPosition, max, PositionBound.startExcluded);
if (lastPosition.compareTo(searchPosition) < 0) {
if (log.isDebugEnabled()) {
log.debug("first position {} matches, last should be {}, but moving to lastPos {}", position,
searchPosition, lastPosition);
}
searchPosition = lastPosition;
}
find();
```
crux of the problem:
The calculated searchPosition may be equal to the current entry position, then, after calling find(), state=checkLast is executed the next time, this causes condition.apply(entry) to be called twice, and with the same entry.
### What did you expect to see?
I'd like to add a check code, for example:
```
if (position.equals(searchPosition)) {
callback.findEntryComplete(position, OpFindNewest.this.ctx);
return;
}
```
```
case checkFirst:
if (!condition.apply(entry)) {
// If no entry is found that matches the condition, it is expected to pass null to the callback.
// Otherwise, a message before the expiration date will be deleted due to message TTL.
// cf. https://github.com/apache/pulsar/issues/5579
callback.findEntryComplete(null, OpFindNewest.this.ctx);
return;
} else {
lastMatchedPosition = position;
// check last entry
state = State.checkLast;
PositionImpl lastPosition = ledger.getLastPosition();
searchPosition = ledger.getPositionAfterN(searchPosition, max, PositionBound.startExcluded);
if (position.equals(searchPosition)) {
callback.findEntryComplete(position, OpFindNewest.this.ctx);
return;
}
if (lastPosition.compareTo(searchPosition) < 0) {
if (log.isDebugEnabled()) {
log.debug("first position {} matches, last should be {}, but moving to lastPos {}", position,
searchPosition, lastPosition);
}
searchPosition = lastPosition;
}
find();
}
break;
```
### What did you see instead?
condition.apply(entry) is executed twice
### Anything else?
no
### Are you willing to submit a PR?
- [X] I'm willing to submit a 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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] mingyifei closed issue #19808: [Bug] org.apache.bookkeeper.mledger.impl.OpFindNewest#readEntryComplete
Posted by "mingyifei (via GitHub)" <gi...@apache.org>.
mingyifei closed issue #19808: [Bug] org.apache.bookkeeper.mledger.impl.OpFindNewest#readEntryComplete
URL: https://github.com/apache/pulsar/issues/19808
--
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