codelipenghui commented on code in PR #21969:
URL: https://github.com/apache/pulsar/pull/21969#discussion_r1469595424
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:
##########
@@ -2213,8 +2216,23 @@ private void getLargestBatchIndexWhenPossible(
return;
}
- if (lastPosition.getEntryId() == -1 || (compactionHorizon != null
- && lastPosition.compareTo((PositionImpl)
compactionHorizon) <= 0)) {
+ if (lastPosition.getEntryId() == -1 ||
!ml.ledgerExists(lastPosition.getLedgerId())) {
+ // there is no entry in the original topic
+ if (readCompacted) {
+ // if readCompacted is true, we need to read the last
entry from compacted topic
+ handleLastMessageIdFromCompactionService(persistentTopic,
requestId, partitionIndex,
+ markDeletePosition);
+ } else {
+ // if readCompacted is false, we need to return
MessageId.earliest
+
writeAndFlush(Commands.newGetLastMessageIdResponse(requestId, -1, -1,
partitionIndex, -1,
+ markDeletePosition != null ?
markDeletePosition.getLedgerId() : -1,
+ markDeletePosition != null ?
markDeletePosition.getEntryId() : -1));
+ }
+ return;
Review Comment:
nit:
```diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
index ab4758d5be..3ab25eb098 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
@@ -2218,7 +2218,7 @@ public class ServerCnx extends PulsarHandler
implements TransportCnx {
if (lastPosition.getEntryId() == -1 ||
!ml.ledgerExists(lastPosition.getLedgerId())) {
// there is no entry in the original topic
- if (readCompacted) {
+ if (compactionHorizon != null) {
// if readCompacted is true, we need to read the last
entry from compacted topic
handleLastMessageIdFromCompactionService(persistentTopic, requestId,
partitionIndex,
markDeletePosition);
@@ -2231,8 +2231,7 @@ public class ServerCnx extends PulsarHandler
implements TransportCnx {
return;
}
- if (readCompacted && compactionHorizon != null
- && lastPosition.compareTo((PositionImpl)
compactionHorizon) <= 0) {
+ if (compactionHorizon != null &&
lastPosition.compareTo((PositionImpl) compactionHorizon) <= 0) {
handleLastMessageIdFromCompactionService(persistentTopic,
requestId, partitionIndex,
markDeletePosition);
return;
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]